npm install安装失败

请注意,本文编写于  1,012  天前,最后编辑于  1,002  天前,内容可能已经不具有时效性,请谨慎参考。

npm install安装失败

错误信息

使用npm install时,出现错误,具体报错如下
image.png

npm WARN tarball tarball data for monaco-editor@0.15.6 (sha512-JoU9V9k6KqT9R9Tiw1RTU8ohZ+Xnf9DMg6Ktqqw5hILumwmq7xqa/KLXw513uTUsWbhtnHoSJYYR++u3pkyxJg==) seems to be corrupted. Trying one more time.
npm ERR! path F:\smy\smy_front_end\node_modules\.staging\monaco-editor-4749162a\dev\vs\editor\editor.main.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'F:\smy\smy_front_end\node_modules\.staging\monaco-editor-4749162a\dev\vs\editor\editor.main.js'    
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'F:\smy\smy_front_end\node_modules\.staging\monaco-editor-4749162a\dev\vs\editor\editor.main.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'F:\smy\smy_front_end\node_modules\.staging\monaco-editor-4749162a\dev\vs\editor\editor.main.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'F:\\smy\\smy_front_end\\node_modules\\.staging\\monaco-editor-4749162a\\dev\\vs\\editor\\editor.main.js' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'F:\\smy\\smy_front_end\\node_modules\\.staging\\monaco-editor-4749162a\\dev\\vs\\editor\\editor.main.js\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'F:\\smy\\smy_front_end\\node_modules\\.staging\\monaco-editor-4749162a\\dev\\vs\\editor\\editor.main.js',
npm ERR!   parent: 'smy' }
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).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\39060\AppData\Roaming\npm-cache\_logs\2020-06-21T07_20_48_781Z-debug.log

解决方法

1.使用cnpm

命令如下

cnpm install

安装过程中没出错,但npm start时出错

2.使用国内镜像

命令如下,使用淘宝源

npm install --registry=https://registry.npm.taobao.org

安装过程会卡住,结束该过程,切换梯子为全局代理后,继续尝试该命令
安装成功

猜测应该是下载过程中出错,可以切换网络多试几次