代码之家  ›  专栏  ›  技术社区  ›  Fil

sh:1:节点:权限被拒绝

  •  7
  • Fil  · 技术社区  · 7 年前

    试图在ubuntu 18.04上运行这个命令

    npm install -g pngquant-bin
    

    [..................] | fetchMetadata: sill resolveWithNewModule npm-conf@1.1.3 checking installable status
    npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
    /root/.nvm/versions/node/v10.8.0/bin/pngquant -> /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin/cli.js
    
    > pngquant-bin@5.0.0 postinstall /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin
    > node lib/install.js
    
    sh: 1: node: Permission denied
    npm ERR! file sh
    npm ERR! code ELIFECYCLE
    npm ERR! errno ENOENT
    npm ERR! syscall spawn
    npm ERR! pngquant-bin@5.0.0 postinstall: `node lib/install.js`
    npm ERR! spawn ENOENT
    npm ERR!
    npm ERR! Failed at the pngquant-bin@5.0.0 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2018-08-12T18_08_02_197Z-debug.log
    

    你知道怎么处理这个吗? articles 但没有成功。

    4 回复  |  直到 6 年前
        1
  •  40
  •   Rooney    6 年前

    同样的错误 sh: 1: node: Permission denied

    所以这对我有效

    npm config set user 0
    npm config set unsafe-perm true
    
        2
  •  2
  •   FChiri    6 年前

    sudo chown-R USERID.USERID*

        3
  •  1
  •   Paul Whittaker    6 年前

    /root/.npm/... 原始消息中的日志路径显示您已经以根用户身份运行,并且(尽管其他人建议)我认为这很可能是 你的问题。

    我(有限的)以根用户身份运行节点的经验是 npm install 在Ubuntu上。只需使用普通用户帐户下载并解压缩节点安装。

    对我来说,作为根用户运行至少有一个问题是因为某种依赖关系 npm安装 脚本正在调用 setuid 切换到特权较低的用户。由于某种原因,它选择了Ubuntu上不存在的UID 500,因此失去了它的所有特权。因此,“权限被拒绝”错误是 因为 我像根一样奔跑; 对普通用户不起作用。

    我相信这和 Error: setuid user id does not exist npm ERR! when npm install forever -g .

        4
  •  0
  •   user1247071 user1247071    7 年前

    你需要根用户权限,只需添加 sudo

    sudo npm install -g pngquant-bin
    
        5
  •  0
  •   Марат Зимнуров    5 年前

    尝试在项目文件夹中安装节点

    npm install node
    
        6
  •  0
  •   anthony sottile    5 年前

    另外(这可能对 docker npm_config_user --例如:

    ENV npm_config_user=root