节点中的jest安装获取错误gyp ERR!堆栈错误:EACCES:权限被拒绝,rmdir' build'

时间:2018-04-11 19:48:11

标签: node.js node-modules jest permission-denied node-gyp

我尝试通过运行以下命令来安装jest。

sudo npm install -g jest

导致错误,为了解决此问题,我尝试了以下命令。

  1. 尝试将node-gyp更新为最新版本。 npm explore npm -g -- npm install node-gyp@latest

  2. 按照以下命令解决任何访问问题。

    sudo chown -R $USERNAME:$GROUP ~ sudo chown -R $USERNAME:$GROUP /usr/local//lib/node_modules/ sudo chown -R $USERNAME:$GROUP /usr/local/Cellar/node/

  3. 我正在使用macbook并尝试在我的主目录下的文件夹中安装。 我是节点的新手,非常感谢任何帮助解决。

    抛出以下错误:

    node-pre-gyp ERR! Tried to download(undefined): https://fsevents- 
    binaries.s3-us-west-2.amazonaws.com/v1.1.3/fse-v1.1.3-node-v59- 
    darwin-x64.tar.gz
    node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.3 and 
    node@9.9.0 (node-v59 ABI, unknown) (falling back to source compile 
    with node-gyp)
    gyp ERR! clean error
    gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
    gyp ERR! System Darwin 17.5.0
    gyp ERR! command "/usr/local/Cellar/node/9.9.0/bin/node" 
    "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node- 
    gyp.js" "clean"
    gyp ERR! cwd /usr/local/lib/node_modules/jest/node_modules/fsevents
    gyp ERR! node -v v9.9.0
    gyp ERR! node-gyp -v v3.6.2
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute 
    '/usr/local/Cellar/node/9.9.0/bin/node 
    /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js 
    clean' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> 
    (/usr/local/lib/node_modules/jest/node_modules/fsevents/node_modules/
    node-pre-gyp/lib/util/compile.js:83:29)
    node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
    node-pre-gyp ERR! stack     at maybeClose 
    (internal/child_process.js:936:16)
    node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit 
    (internal/child_process.js:220:5)
    node-pre-gyp ERR! System Darwin 17.5.0
    node-pre-gyp ERR! command "/usr/local/Cellar/node/9.9.0/bin/node" 
    "/usr/local/lib/node_modules/jest/node_modules/fsevents/node_modules/
    node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd 
    /usr/local/lib/node_modules/jest/node_modules/fsevents
    node-pre-gyp ERR! node -v v9.9.0
    node-pre-gyp ERR! node-pre-gyp -v v0.6.39
    node-pre-gyp ERR! not ok
    Failed to execute '/usr/local/Cellar/node/9.9.0/bin/node 
    /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js 
    clean' (1)
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 
    (node_modules/jest/node_modules/fsevents):
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 
    install: `node install`
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
    

1 个答案:

答案 0 :(得分:0)

尝试此命令:

sudo npm install -g --unsafe-perm