【问题标题】:Unforseen errors when running sudo npm install -g @vue/cli运行 sudo npm install -g @vue/cli 时出现不可预见的错误
【发布时间】:2018-12-11 14:40:20
【问题描述】:

除了通过cli 启动并运行vue.js 的危险银弹chown -R 解决方案之外,我已经尝试了网络上的所有解决方案。

据说,我无权操作 npm 文件夹,但我还是不太确定。

Terminal 中,我收到以下错误。我已经谷歌一一搜索错误,尝试了一些潜在的解决方案,但没有任何效果。

我能做些什么来解决这个问题?

node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.4 and node@11.3.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/jamf/bin/lib/node_modules/@vue/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64' 
gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/jamf/bin/jamf/node" "/usr/local/jamf/bin/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean"
gyp ERR! cwd /usr/local/jamf/bin/lib/node_modules/@vue/cli/node_modules/fsevents
gyp ERR! node -v v11.3.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/jamf/bin/jamf/node /usr/local/jamf/bin/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/jamf/bin/lib/node_modules/@vue/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/jamf/bin/jamf/node" "/usr/local/jamf/bin/lib/node_modules/@vue/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/jamf/bin/lib/node_modules/@vue/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v11.3.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/jamf/bin/jamf/node /usr/local/jamf/bin/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean' (1)
npm WARN @apollographql/apollo-upload-server@5.0.3 requires a peer of graphql@^0.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/@vue/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @vue/cli@3.2.1

【问题讨论】:

    标签: javascript debugging vue.js terminal vuejs2


    【解决方案1】:

    您可以使用chown -R 选项。因为它试图访问的文件夹是由另一个进程创建的,所以您的用户帐户不是所有者,因此无法在那里进行更改。当您使用chown -R 时,您只需将文件夹的所有权更改为您的用户,这并不危险。我不得不在我的新笔记本电脑上为 npm 做几次。

    您要使用的命令是:

    sudo chown &lt;username&gt; -R ./*

    在文件夹中:/usr/local/jamf/bin/lib 我认为,如果这不起作用,请尝试向上一个文件夹并在那里使用相同的命令。

    【讨论】:

    • 嘿米卡,你能推荐确切的chown -R 命令吗?也许您可能知道与我之前尝试过的大量命令不同的东西。另外,npm 可访问性是我面临的问题吗?
    • 我添加了您需要使用的确切命令。而且您的用户帐户并不拥有它试图更改的文件夹,因此操作系统不允许您这样做,即使使用 sudo。所以它不一定是 npm,只是你的操作系统。到目前为止,我还没有在 Windows 上看到此类问题,但我在 Linux 和 MacOs 上遇到过。
    • 我试过了,但它不起作用。我输入了带有和不带有 &lt;&gt; 的机器用户名,但我收到错误消息:chown: -R: No such file or directory
    • 抱歉命令出错,*告诉它匹配所有文件和文件夹
    • 我去掉了 * 但我仍然遇到同样的错误。我什至去了 1 个文件夹并使用了相同的命令,但仍然得到相同的错误:(.
    【解决方案2】:
    sudo npm install -g @vue/cli --unsafe-perm
    

    看到这个vue-cli issue on GitHub

    【讨论】:

      猜你喜欢
      • 2020-11-01
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 2021-08-25
      相关资源
      最近更新 更多