【问题标题】:Vue CLI install issuesVue CLI 安装问题
【发布时间】:2020-05-25 01:09:33
【问题描述】:

我正在学习 Vue.JS,我需要安装 Vue CLI。

NodeJS:v13.8.0 Vue CLI:v4.2.2

我安装 NodeJS 没有问题,但是当我转到终端上的文件夹并使用 (npm install -g @vue/cli) 安装 Vue CLI 时出现很多错误。

MacBook-Pro-de-Cedric:excli cedric$ npm install -g @vue/cli
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/cli/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/@vue/cli
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@vue/cli'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@vue/cli'] {
npm ERR!   stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@vue/cli'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/@vue/cli'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cedric/.npm/_logs/2020-02-09T15_09_00_595Z-debug.log

我可以通过终端创建一个项目:(vue create nameofproject) 但它也包含错误,我无法启动 npm run serve

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/cedric/Documents/Projets Site Web : Apps/VueJs/excli/projet/node_modules/fsevents
gyp ERR! node -v v13.8.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 

Successfully created project projet.
Get started with the following commands:

 $ cd projet
 $ npm run serve

MacBook-Pro-de-Cedric:excli cedric$ npm run serve
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/cedric/Documents/Projets Site Web : Apps/VueJs/excli/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/cedric/Documents/Projets Site Web : Apps/VueJs/excli/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cedric/.npm/_logs/2020-02-09T15_18_01_082Z-debug.log

如果有人知道我该如何解决,那就太好了。 谢谢

【问题讨论】:

  • 这些错误看起来与 Vue CLI 没有直接关系。它们看起来像是您的 npm 设置的问题。您可能需要谷歌搜索与 npm、macOS 和 相关的答案,例如 flaviocopes.com/npm-fix-missing-write-access-error
  • 很多错误都包含在 questino... EACCES 意味着您需要使用 sudo 或为用户安装 npm,例如 google 周围 how to install nvm on MacOs 其他部分是 gyp eror
  • 感谢大家的回答,我找到了问题所在。我试图在目录上创建一个项目。当我在 /user/myname 上创建它时它可以工作!

标签: node.js vue.js vuejs2 command-line-interface


【解决方案1】:

如果您使用的是 mac,请尝试使用 sudo npm install -g @vue/cli 而不是 npm install -g @vue/cli 进行全局安装。

【讨论】:

    【解决方案2】:

    由于Node模块路径丢失,直接输入sudo npm install -g @vue/cli即可安装vue,即全局环境下安装vue,也可以重新设置node模块路径。

    【讨论】:

      【解决方案3】:

      您必须以超级用户权限执行npm install -g(以sudo 为例,在Linux 上),因为您的npm 目录似乎在超级用户权限下。

      你也可以change the npm's default directory

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-04-20
        • 2018-03-14
        • 2021-06-04
        • 2021-05-20
        • 2021-06-17
        • 1970-01-01
        • 2021-11-16
        相关资源
        最近更新 更多