javascript node-sass 安装问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45876943/
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
node-sass installation issue
提问by Alwin
When I try to install node-sass using npm, I get the following error message:
当我尝试使用 npm 安装 node-sass 时,我收到以下错误消息:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":"
无法下载“ https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node”:
The command I use is:
我使用的命令是:
npm install node-sass --save-dev-
You can see more details in the screenshot below:
您可以在下面的屏幕截图中看到更多详细信息:


回答by Ravi Maroju
After struggling , finally found exact solution. In node js software folder, node-sass\4.5.0 folder is still created in npm-cache folder. So I download win32-x64-48_binding.node manually, put it in C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.5.0 folder.
苦苦挣扎,终于找到了确切的解决办法。在 node js 软件文件夹中, node-sass\4.5.0 文件夹仍然创建在 npm-cache 文件夹中。所以我手动下载了win32-x64-48_binding.node,放到C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.5.0文件夹下。
And run npm install command, issue resolved.
并运行 npm install 命令,问题解决。
回答by Nico Van Belle
I see you are running node version 8.1.4. You can also check it using node --versionin the command prompt.
我看到您正在运行节点版本 8.1.4。您也可以node --version在命令提示符中使用它来检查它。
You'll have to use a version >= v4.5.3 instead because lower versions of node-sass are incompatible with node8. This issue has been reported on their GitHub issue page.
You either have to define using v4.5.3 instead or pass the the -gparameter while installing it, which seems to fetch the latest version automagically.
您必须改用版本 >= v4.5.3,因为较低版本的 node-sass 与 node8 不兼容。此问题已在他们的 GitHub 问题页面上报告。您要么必须使用 v4.5.3 来定义,要么-g在安装时传递参数,这似乎会自动获取最新版本。
when i used -g it worked properly and got the latest version
当我使用 -g 时它工作正常并获得了最新版本
Also, as @javiergarvalhas pointed out, you have a typo. It should have been --save-devinstead of --save-dev-.
另外,正如@javiergarval所指出的,你有一个错字。它应该是--save-dev而不是--save-dev-.
回答by emonkey
My problem is, that I need an older node-sassBinary, which is not available for the new node version I have. But the solution is, at least on Windows, pretty simple. Just install the windows build tools. With that, npm is able to build the binaries out of the source.
我的问题是,我需要一个较旧的node-sass二进制文件,它不适用于我拥有的新节点版本。但至少在 Windows 上,解决方案非常简单。只需安装 Windows 构建工具。这样,npm 就能够从源代码中构建二进制文件。
Long story short, this solved the problem for me:
长话短说,这为我解决了问题:
npm install --global --production windows-build-tools
Thanks to the answer on this question: node-sass installation issue on windows 10
感谢对这个问题的回答: windows 10 上的 node-sass 安装问题
回答by javiergarval
You have an error on your command:
您的命令有错误:
$ npm install node-sass --save-dev-
^^^
Should be
应该
$ npm install node-sass --save-dev
(without the last - on dev)
(没有最后一个 - 在开发上)
Also, it is giving you a WARNING because it wants to be installed globally.
此外,它向您发出警告,因为它希望在全球范围内安装。
See the official node-sass documentation.
请参阅官方 node-sass文档。
And also, could be interesting for you to know the differences between --saveand --save-dev.
而且,了解--save和--save-dev之间的区别对您来说可能很有趣。
回答by Bamieh
Depends on which node version you are using. Node-Sass currently supports only these versions:
取决于您使用的节点版本。Node-Sass 目前仅支持以下版本:
Supported Node.js versions 0.10, 0.12, 1, 2, 3, 4, 5, 6 and 7.
支持的 Node.js 版本 0.10、0.12、1、2、3、4、5、6 和 7。
If you happen to work on one of those versions, try to specify which version of node-sassyou want:
如果您碰巧使用这些版本之一,请尝试指定node-sass您想要的版本:
$ npm install --save-dev [email protected]
your npm is trying to download node-sassversion 3.31.1which is does not exist on the releases page of https://github.com/sass/node-sass/releases
您的NPM正试图下载node-sass的版本3.31.1是的发布页上不存在https://github.com/sass/node-sass/releases
回答by Mayank Nimje
While searching for the solution, have checked the release versions of node-sass and found that "https://github.com/sass/node-sass/releases" the node file it was looking is committed in the latest release and not in the older version. After downloading the required file "win32-x64-64_binding.node" manually from the released version and placing it under C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.7.2 or simply by using npm install node-sass@latest works for me.
在寻找解决方案时,检查了 node-sass 的发布版本,发现“ https://github.com/sass/node-sass/releases”它正在查找的节点文件在最新版本中提交,而不是在旧版本。从已发布的版本手动下载所需的文件“ win32-x64-64_binding.node”并将其放置在 C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.7.2 或简单地使用 npm安装 node-sass@latest 对我有用。
回答by Bonfix Ngetich
None of the above solutions worked for me, this is what I did:
以上解决方案都不适合我,这就是我所做的:
Installed C++ build tools for Visual Studio
为 Visual Studio 安装的 C++ 构建工具
Then:
然后:
npm uninstall --save-dev gulp-sass

