启动前端项目时,使用npm install
命令一直报错
公司内 node.js 有使用12版本,有使用14版本,故都试了一遍,结果都不能 install 成功
使用 node.js 12.16.2:
25012 error code EPERM
25013 error syscall unlink
25014 error path F:\xxxxx\node_modules\.staging\echarts-2ca3fbc1\dist\echarts-en.js
25015 error errno -4048
25016 error Error: EPERM: operation not permitted, unlink 'F:\xxxxx\node_modules\.staging\echarts-2ca3fbc1\dist\echarts-en.js'
25016 error [OperationalError: EPERM: operation not permitted, unlink 'F:\xxxxx\node_modules\.staging\echarts-2ca3fbc1\dist\echarts-en.js'] {
25016 error cause: [Error: EPERM: operation not permitted, unlink 'F:\xxxxx\node_modules\.staging\echarts-2ca3fbc1\dist\echarts-en.js'] {
25016 error errno: -4048,
25016 error code: 'EPERM',
25016 error syscall: 'unlink',
25016 error path: 'F:\\xxxxx\\node_modules\\.staging\\echarts-2ca3fbc1\\dist\\echarts-en.js'
25016 error },
25016 error stack: "Error: EPERM: operation not permitted, unlink 'F:\\xxxxx\\node_modules\\.staging\\echarts-2ca3fbc1\\dist\\echarts-en.js'",
25016 error errno: -4048,
25016 error code: 'EPERM',
25016 error syscall: 'unlink',
25016 error path: 'F:\\xxxxx\\node_modules\\.staging\\echarts-2ca3fbc1\\dist\\echarts-en.js',
25016 error parent: 'dsm-front'
25016 error }
25017 error The operation was rejected by your operating system.
25017 error It's possible that the file was already in use (by a text editor or antivirus),
25017 error or that you lack permissions to access it.
25017 error
25017 error If you believe this might be a permissions issue, please double-check the
25017 error permissions of the file and its containing directories, or try running
25017 error the command again as root/Administrator.
使用 node.js 14.21.3:
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
多种尝试无果
在网上搜了很多很多方法,但是都没有效果
使用管理员权限打开,删除C:\user\用户名.npmrc 文件,修改镜像,这些方法都没有用
npm install -f
也是报同样的错
删除根目录下 node_modules 文件 执行npm cache clean --force
没有效果
解决方案
通过看报错日志发现主要原因是找不到 ‘npm sass’ 包
使用nodejs v12版本,打开魔法,安装python 2.7.13,删除根目录下的node_modules包,重新 npm install
,完美解决