【ERROR in Cannot find module 'node-sass'】【this.getResolve is not a function】

本文详细记录了解决在安装Sass插件时遇到的权限错误问题,通过降低Sass版本并重新安装,成功解决了Webpack编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在安装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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵宁一

点赞是最好的赞赏~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值