【问题标题】:I get the following npm error on installing Vue Js我在安装 Vue Js 时收到以下 npm 错误
【发布时间】:2020-08-12 10:34:34
【问题描述】:

我在我的 Parrot OS 系统上使用 Snap 安装了 Node.js。

我不知道为什么,但是我在/usr/local/lib 之后没有node_modules 文件夹

这是我使用npm install -g @vue/cli 时遇到的错误

npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
/usr/local/bin/vue -> /usr/local/lib/node_modules/@vue/cli/bin/vue.js
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2913/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> core-js@3.6.5 postinstall /usr/local/lib/node_modules/@vue/cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

2020/08/12 15:51:38.149740 cmd_run.go:918: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/2913": mkdir /nonexistent: permission denied
cannot create user data directory: /nonexistent/snap/node/2913: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/@vue/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @vue/compiler-sfc@3.0.0-rc.5 requires a peer of vue@3.0.0-rc.5 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! core-js@3.6.5 postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the core-js@3.6.5 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/2020-08-12T10_21_41_518Z-debug.log

编辑:-

使用 sudo 时出现以下错误 - sudo: npm: command not found。所以我先运行su,然后尝试npm install -g @vue/cli,但后来我得到了问题中最初提出的错误。

【问题讨论】:

    标签: node.js vue.js npm


    【解决方案1】:

    当您全局安装npm 软件包时,您必须以管理员身份运行安装命令。

    尝试运行,

    sudo npm install -g @vue/cli

    【讨论】:

    • 我试过那个命令,但它说 - sudo: npm: command not found.
    • 解决了我做了一个sudo apt-get install npm。由于某种原因,Node.js 附带的 npm 没有做这件事,所以我不得不单独安装 npm。
    • 感谢@AswinHaridas。这(安装单独的 npm)也为我解决了它(不同的包和错误)。
    猜你喜欢
    • 2018-07-06
    • 2016-03-03
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    • 2021-05-26
    • 2018-02-18
    • 2013-08-06
    • 2021-02-13
    相关资源
    最近更新 更多