当我兴高采烈的打开powershell,劈里啪啦的敲下 npm install -g @vue/cli 命令,按下回车的那一瞬间,我就知道事情不简单(内心有千万只草泥马奔腾)。
没错,报错了,一开始是这样滴:
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 tarball tarball data for typescript@~3.7.5 (sha1-BpLiH2X9QQi5MwI4qsEd0uF3oa4=) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\LXX\AppData\Roaming\npm\node_modules\.staging\rxjs-4dfdb1a4\util\tryCatch.js'
C:\Users\LXX\AppData\Roaming\npm\node_modules\.staging\typescript-d9175e2c\lib\tsserver.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\LXX\AppData\Roaming\npm\node_modules\.staging\typescript-d9175e2c\lib\tsserver.js'
npm ERR! { [Error: EPERM: operation not permitted, lstat 'C:\Users\LXX\AppData\Roaming\npm\node_modules\.staging\typescript-d9175e2c\lib\tsserver.js']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, lstat 'C:\Users\LXX\AppData\Roaming\npm\node_modules\.staging\typescript-d9175e2c\lib\tsserver.js'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\\Users\\LXX\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-d9175e2c\\lib\\tsserver.js' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\LXX\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-d9175e2c\\lib\\tsserver.js\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\\Users\\LXX\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-d9175e2c\\lib\\tsserver.js',
npm ERR! parent: '@vue/cli' }
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 (though this is not recommended).
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 install --save -g core-js@^3
无果!继续。。
有人说可能是npm版本低,于是我升级了一下,npm install -g npm
后续这样滴。。。
我想可能是安装失败的时候有文件残存,又搜了一下,npm cache clear -force,终端powershell回应…sure…doing…什么的,但是还是没用,我已经安装了不下4次。。。
于是乎,我找到node.js的全局安装路径,C:\Users****\AppData\Roaming\npm\node_modules
下,删了这两个文件夹.staging 和 @vue 是前面安装失败留下的文件。
安装了还是失败.
继续执行了npm cache clear -force,再删了这两个文件夹.staging 和 @vue
最有安装了一次,恍恍惚惚的就成功了!
下面是我的node和npm的版本号
于是执行 vue -V测试一下,
没成功?
nonono,这是你笔记本禁止运行脚本,解决办法
输入 set-ExecutionPolicy RemoteSigned
选择 Y或者A,回车
在测试一遍
搞定!