node.js 无法在我的项目中安装 node-sass

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46515077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:30:37  来源:igfitidea点击:

Unable to install node-sass in my project

node.jsnode-sass

提问by sugandh_g

I am doing wes-bos Learn Node course. When I run npm start it shows - cannot find module node-sass. And when I try to run npm install node-sass --save, it gives me the following errors.

我正在做 wes-bos Learn Node 课程。当我运行 npm start 时,它显示 - 找不到模块 node-sass。当我尝试运行时npm install node-sass --save,它给了我以下错误。

Errors

错误

Errors

错误

回答by vikrant

Uninstall node-sass: npm uninstall node-sassDelete package-lock.json, and clean the cache: npm cache clean --force, then do npm update, npm install, npm update. then again try to install node sass: npm install node-sass.

卸载 node-sass:npm uninstall node-sass删除package-lock.json,并清理缓存:npm cache clean --force,然后执行npm update, npm install, npm update。然后再次尝试安装 node sass: npm install node-sass

If this doesn't work, Try to rebuild node-sass:

如果这不起作用,请尝试重建 node-sass:

npm rebuild node-sass

If that too doesn't work then i suggest to delete package-lock.json, node-modulesand npm cachefolder and do npm install, to install all your dependencies again. make sure you have a package.json file with all your dependencies listed.

如果这也不起作用,那么我建议删除package-lock.json, node-modulesand npm cachefolder and do npm install,再次安装所有依赖项。确保您有一个 package.json 文件,其中列出了所有依赖项。

The package-lock.json file has some issues(it doesn't update when package.json changes) as mentioned here:https://github.com/npm/npm/issues/16866"Touching package.json by hand may make your package.json to be incompatible with package-lock.json". do npm updateto update the package-lock.jsonfile. to completely disable package-lock creation: npm config set package-lock false

package-lock.json 文件有一些问题(当 package.json 更改时它不会更新),如下所述:https: //github.com/npm/npm/issues/16866“手动触摸 package.json 可能会使您的 package.json 与 package-lock.json 不兼容”。执行npm update更新package-lock.json文件。完全禁用包锁创建: npm config set package-lock false

回答by Kumar

Try this

尝试这个

sudo npm install -g --unsafe-perm node-sass --save