如何使用npm和nvm安装node-sass?

4
我很难在Mac OS X High Sierra上安装node-sass。我已经安装了nvm,NPM版本为v6.14.1。当我尝试安装node-sass时,会出现错误提示:
 Missing binding /usr/local/lib/node_modules/node-sass/vendor/darwin- 
 x64-48/binding.node
 Node Sass could not find a binding for your current environment: OS 
 X 64-bit with Node.js 6.x

 Found bindings for the following environments:
 - OS X 64-bit with Node.js 9.x

我已经运行了npm rebuild node-sass --force,但问题仍然存在。

2
看起来它试图让你更新nodejs到9.x。你可能需要这样做,或者专门安装一个适用于node 6.x的旧版node-sass。 - jmcgriz
Node-sass有特定的NodeJS版本要求;您必须使用与您的NodeJS版本兼容的版本。 - Dave Newton
哇..问题解决了。安装Node v9.9.0——浪费了5个小时。非常感谢你们两位! - runners3431
1个回答

0

我使用yarn进行了安装,但是遇到了很多错误。在尝试了各种技巧(例如npm rebuild node-sass或删除$HOME/.node-gyp)之后,最终解决方法是以root权限运行命令:

sudo yarn add --dev node-sass.

在您的情况下,应该是:

sudo npm install node-sass

希望能对您有所帮助!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接