在安装sass插件时报错
$ npm install sass-loader node-sass --save-dev
//返回的报错信息
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\jinwe\truth_hold\node_modules\node-sass\node_modules
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\jinwe\truth_hold\node_modules\node-sass\node_modules'
npm ERR! [OperationalError: EPERM: operation not permitted, mkdir 'C:\Users\jinwe\truth_hold\node_modules\node-sass\node_modules'] {
npm ERR! cause: [Error: EPERM: operation not permitted, mkdir 'C:\Users\jinwe\truth_hold\node_modules\node-sass\node_modules'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\jinwe\\truth_hold\\node_modules\\node-sass\\node_modules'
npm ERR! },
npm ERR! stack: "Error: EPERM: operation not permitted, mkdir 'C:\\Users\\jinwe\\truth_hold\\node_modules\\node-sass\\node_modules'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\jinwe\\truth_hold\\node_modules\\node-sass\\node_modules',
npm ERR! parent: 'truth_hold'
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\jinwe\AppData\Roaming\npm-cache\_logs\2019-11-05T01_54_51_276Z-debug.log
C:\Users\jinwe\truth_hold>npm run dev
> truth_hold@1.0.0 dev C:\Users\jinwe\truth_hold
> node build/dev-server.js wx
ERROR Failed to compile with 2 errors
这时运行npm ls
,会出现这个下面的错误
$ npm ls
//返回的报错信息
npm ERR! peer dep missing: webpack@^4.36.0, required by sass-loader@8.0.0
npm ERR! peer dep missing: vue-template-compiler@^2.0.0, required by vue-loader@13.7.3
并且启动项目的时候报错
$ npm run dev
//返回的错误信息,已简化
ERROR in Cannot find module 'node-sass'
this.getResolve is not a function
这是因为当前sass的版本太高,webpack编译时出现了错误,这个时候只需要换成低版本的就行
修改package.json文件,将里面的 "sass-loader"的版本换成更低的版本,比如我现在是"sass-loader": "^8.0.0"
换成了"sass-loader": "^7.3.1"
重新安装sass,再启动项目就成功了
//重新安装sass
$ npm install sass-loader node-sass --save-dev
//启动项目
$ npm run dev