node.js 更新 NodeJS 后使用 node-sass 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38652404/
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 20:26:50  来源:igfitidea点击:

Issue using node-sass after updating NodeJS

node.jsnode-sass

提问by tonymx227

I get an issue using node-sassafter updating my NodeJS version.

node-sass更新我的 NodeJS 版本后,我在使用时遇到问题。

Issue :

问题 :

(node:472) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
C:\aglqng\src\main\webapp\node_modules\node-sass\lib\index.js:15
    throw new Error(errors.missingBinary());
    ^

Error: Missing binding C:\aglqng\src\main\webapp\node_modules\node-sass\vendor\win32-x64-48\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x

Found bindings for the following environments:
  - Windows 64-bit with Node 0.12.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
    at Object.<anonymous> (C:\aglqng\src\main\webapp\node_modules\node-sass\lib\index.js:15:11)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\aglqng\src\main\webapp\node_modules\gulp-sass\index.js:187:21)
    at Module._compile (module.js:541:32)

Versions :

版本:

node-sass 3.8.0 (Wrapper) [JavaScript]
libsass 3.3.6 (Sass Compiler) [C/C++]
nodejs v6.3.1

Platform :Windows 10 x64

平台:Windows 10 x64

I tried this and it doesn't work :

我试过这个,但它不起作用:

1)

1)

node rebuild node-sass

2)

2)

npm uninstall node-sass
npm i node-sass

回答by Scott

I was able to fix this issue by just running this command:

我只需运行以下命令即可解决此问题:

npm install node-sass

回答by nschonni

If the rebuild command didn't work for you, try deleting the "node_modules" directory and reinstall.

如果重建命令对您不起作用,请尝试删除“node_modules”目录并重新安装。

回答by Vinod Kumar

You can run the:

您可以运行:

npm rebuild node-sass

回答by Blaze

I encountered the issue when I updated to VS 2017. VS comes with its own installation of Node, which might not be the most updated one that exists on your system. To override this follow the following steps:

我在更新到 VS 2017 时遇到了这个问题。 VS 自带了自己的 Node 安装,这可能不是您系统上最新的安装。要覆盖它,请执行以下步骤:

  1. Go to Tools -> Options -> Project and Solutions -> Web Package Management
  2. In "Location of External Tools" Add a new entry which points to nodejs install location, like: "C:\Program Files\nodejs"
  3. Make sure it is above other entries.
  1. 转到工具 -> 选项 -> 项目和解决方案 -> Web 包管理
  2. 在“外部工具的位置”中添加一个指向 nodejs 安装位置的新条目,例如:“C:\Program Files\nodejs”
  3. 确保它高于其他条目。

I found a really helpful article here, which informed me on above points.

我在这里找到了一篇非常有用的文章,它告诉了我上述几点。

[Note: If needed, first update nodejs on your system. On windows, this is done by making a fresh install of new version.]

[注意:如果需要,请先更新系统上的 nodejs。在 Windows 上,这是通过全新安装新版本来完成的。]

回答by abelabbesnabi

Remove node_modules then run npm install at project root

删除 node_modules 然后在项目根目录运行 npm install

回答by Brandy23

this works for me: Synchronize Node.JS Install Version with Visual Studio 2015

这对我有用:Synchronize Node.JS Install Version with Visual Studio 2015

1) find the Node.js installation you already have and use at the command line. By default, Node.js 0.12.7 installs to “C:\Program Files\nodejs”, as an FYI.

1) 找到您已有的 Node.js 安装并在命令行中使用。默认情况下,Node.js 0.12.7 安装到“C:\Program Files\nodejs”,仅供参考。

2) Once you've got that all copied out to your clipboard, got to Tools > Options in Visual Studio 2015. In this dialog, go to Projects and Solutions > External Web Tools to open the dialog that manages all of the 3rd party tools used within VS. This is where Node.js is pointed to.

2) 将所有内容复制到剪贴板后,转到 Visual Studio 2015 中的“工具”>“选项”。在此对话框中,转到“项目和解决方案”>“外部 Web 工具”以打开管理所有 3rd 方工具的对话框在 VS 中使用。这就是 Node.js 所指向的地方。

3)Add an entry at the top to the path to the node.js directory to force Visual Studio to use that version instead.

3) 在顶部添加一个条目到 node.js 目录的路径,以强制 Visual Studio 使用该版本。

thanks to: https://ryanhayes.net/synchronize-node-js-install-version-with-visual-studio-2015/

感谢:https: //ryanhayes.net/synchronize-node-js-install-version-with-visual-studio-2015/

回答by itay oded

I had the same issue on windows, I have solved it by doing the following:

我在 Windows 上遇到了同样的问题,我通过执行以下操作解决了它:

1) open terminal as administrator

1)以管理员身份打开终端

2) run npm rebuild node-sass

2)运行 npm rebuild node-sass

3) run npm ci

3)运行 npm ci

回答by Jerry Chong

I have this error when code repository is originally complied in macOS Mojave, and run it on Windows 10.

当代码存储库最初在 macOS Mojave 中编译并在 Windows 10 上运行时,出现此错误。

Just use following command to fix this error:

只需使用以下命令来修复此错误:

npm rebuild node-sass

After run the command, then run ng serveagain.

运行命令后,再次运行ng serve

回答by Anusuya Goud

Instead of deleting node-Modules, running below helps:

而不是删除node-Modules,在下面运行有助于:

cd <Your project path>
node node_modules/node-sass/scripts/install.js

回答by Alok Srivastav

If the issue still prevails after running npm rebuild node-sass, follow as below

如果运行后问题仍然存在npm rebuild node-sass,请按照以下步骤操作

  1. delete node_modules folder
  2. run 'npm install',
  3. npm rebuild node-sass,
  4. run command for respective environment.
  1. 删除 node_modules 文件夹
  2. 运行'npm install',
  3. npm 重建节点 sass,
  4. 为各自的环境运行命令。