node.js 找不到模块“node-sass”中的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48147896/
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
ERROR in Cannot find module 'node-sass'
提问by bier hier
Config: macOS High Sierra, version 10.13.2, node:v8.1.2 npm:5.0.3 When I run npm start in my angularjs project I get this error:
配置:macOS High Sierra,版本 10.13.2,节点:v8.1.2 npm:5.0.3 当我在我的 angularjs 项目中运行 npm start 时,我收到此错误:
ERROR in Cannot find module 'node-sass'
After this I run:
在此之后我运行:
npm i node-sass
Now I get this error:
现在我收到这个错误:
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
Why won't npm install node-sass? How can I install node-sass?
为什么 npm 不安装 node-sass?如何安装 node-sass?
回答by Alex Onozor
Here's the solution:
这是解决方案:
sudo npm install --save-dev --unsafe-perm node-sass
Enjoy!
享受!
回答by kedar kokil
- This error is for node-sass is not present ... to solve this just you want to run following command
- 这个错误是因为 node-sass 不存在......要解决这个问题,你只想运行以下命令
npm install node-sass
npm install node-sass
回答by PENG ZHU
Run:
跑:
npm rebuild node-sass --force
and it'll work fine.
它会正常工作。
回答by Bandham Manikanta
Doing npm uninstall node-sassand then npm i node-sass, not worked for me.
做npm uninstall node-sass然后npm i node-sass,对我不起作用。
Solution worked for me is npm install --save-dev node-sass.
对我有用的解决方案是npm install --save-dev node-sass.
Happy Coding..
快乐编码..
回答by ohkts11
According to node-sass github page, supported node.js version vary release by release.
根据 node-sass github 页面,支持的 node.js 版本因版本而异。
https://github.com/sass/node-sass
https://github.com/sass/node-sass
Example: Check the version of node you are running.
示例:检查您正在运行的节点版本。
node -v
-> v12.0.0
you need node-sass v4.12+. so you can
你需要 node-sass v4.12+。这样你就可以
npm install [email protected]
or if 4.12.0 is the latest
或者如果 4.12.0 是最新的
npm install node-sass@latest
(npm install node-sasswill install the latest version in many cases, but remember that it does not always install the latest(in this example 4.12.0) if dependency in package.json is written like ^3.0.0, ~4.11.0)
What's the difference between tilde(~) and caret(^) in package.json?
(npm install node-sass在很多情况下会安装最新版本,但请记住,如果 package.json 中的依赖项写成 ^3.0.0, ~4.11.0,它并不总是安装最新版本(在本例中为 4.12.0)有
什么区别在 package.json 中的波浪号(~)和插入符号(^)之间?
Lastly, using sudo with npm is not a good practice. Please refer to this article. https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92
最后,在 npm 中使用 sudo 不是一个好习惯。请参考这篇文章。 https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92
回答by Vibhu kumar
It worked for me...
它对我有用...
sudo npm rebuild node-sass --force
回答by zardilior
node-sassis not being installed and it can be one of many reasons
未安装node-sass这可能是许多原因之一
You have not installed it
你还没有安装
npm install node-sass --save-dev
You are having a permissions error
您遇到权限错误
sudo npm install --save-dev --unsafe-perm node-sass
You had a memory issue because it tried to make it (build from c code in your platform),this applies to some platforms and node versions
你有一个内存问题,因为它试图让它(从你平台中的 c 代码构建),这适用于某些平台和节点版本
node --max_old_space_size=8000 $(which npm) install node-sass --save-dev
Your node and npm versions are not compatible,which most probably generated a failure in the build process,
您的 node 和 npm 版本不兼容,这很可能在构建过程中导致失败,
In this case use n or nvm to make sure you have the same version in the new and original environment, the one where it did work, as this is usually by using different versions in different environments
在这种情况下,使用 n 或 nvm 来确保您在新环境和原始环境中具有相同的版本,它确实可以工作,因为这通常是通过在不同的环境中使用不同的版本
回答by Andreas Gassmann
It failed for me because I was using the latest version of node (12.7.0) I then had to explicitly install the latest version of node-sasswith:
它对我来说失败了,因为我使用的是最新版本的节点(12.7.0),然后我必须明确安装最新版本的node-sass:
npm install [email protected]
npm install [email protected]
回答by Olu Ayeni
This is what worked for me. I first uninstall node-sass. Then install it back.
这对我有用。我首先卸载 node-sass。然后装回去。
npm uninstall node-sass
npm install --save-dev node-sass
npm uninstall node-sass
npm install --save-dev node-sass
回答by Joffrey Hernandez
I have fix this problem without installing node-sass by this command:
我已经解决了这个问题,而没有通过这个命令安装 node-sass:
npm install [email protected] --no-save --unsafe-perm


