安装vue cli3遇到的问题

在nodejs目录下输入命令npm install -g @vue/cli

报错如下:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2019-10-13T07_14_36_961Z-debug.log

解决办法:

npm install  @vue/cli -g --ignore-scripts
npm install protobufjs  -g --ignore-scripts

再查看vue --version成功了

参考文章:

https://stackoverflow.com/questions/53017176/vue-cli-npm-install-error-elifecycle-enoent-spawn-protobufjs

查看vue版本的时候报错:

扫描二维码关注公众号,回复: 9908623 查看本文章

internal/modules/cjs/loader.js:783
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\@vue\cli\bin\vue.js'
[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:685:27)[39m
[90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)[39m
[90m    at internal/main/run_main_module.js:17:11[39m {
  code: [32m'MODULE_NOT_FOUND'[39m,
  requireStack: []
}

解决方法:

是因为vue脚手架没有全局安装。

npm install -g @vue/cli

参考文章:

https://blog.csdn.net/YuSina_/article/details/88870517

卸载已经安装的webpack时候出现报错:

npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_modules\.staging
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
npm ERR!  [OperationalError: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'mkdir',
npm ERR!     path: 'C:\\Program Files\\nodejs\\node_modules\\.staging'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, mkdir 'C:\\Program Files\\nodejs\\node_modules\\.staging'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Program Files\\nodejs\\node_modules\\.staging'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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!     C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2019-10-13T07_18_28_238Z-debug.log

解决方法:

重点是这里的:npm ERR! Error: EPERM: operation not permitted

其实就是权限问题,使用管理员权限应该OK。

选择"使用管理员权限运行CMD";然后继续输入命令即可。

参考文章:

https://blog.csdn.net/qq_41648452/article/details/80630598

发布了59 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41160739/article/details/102533899