node.js 如何修复“fs:不支持重新评估本机模块源”-graceful-fs

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

How to fix 'fs: re-evaluating native module sources is not supported' - graceful-fs

node.jsnpmnode-modulesnpm-install

提问by shershen

Recently I've made a switch to Node v.6, and It started creating more and more problems with running normal builds grunt/gulp/webpack

最近我切换到 Node v.6,它开始在运行正常构建时产生越来越多的问题 grunt/gulp/webpack

For example:

例如:

$ gulp
[14:02:20] Local gulp not found in ~/_Other/angular-2-ts/angular2-seed
[14:02:20] Try running: npm install gulp

while gulp and all other plugins and modules are installed (and even re-installed via rm -rf node_modules) in /node_modules folder.

而 gulp 和所有其他插件和模块安装(甚至通过 重新安装rm -rf node_modules)在 /node_modules 文件夹中。

Most of those errors have line like

大多数错误都有类似的行

(node:42) 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.

with 42 as arbitrary number

以 42 作为任意数字

Like in that issue I've submitted - in angular2-seed repo https://github.com/mgechev/angular2-seed/issues/902

就像我提交的那个问题一样 - 在 angular2-seed repo https://github.com/mgechev/angular2-seed/issues/902

What I've tried to do is downgrade to Node v.5 via n (https://www.npmjs.com/package/n) - it worked. Then remove all node_modulesfolders, then do

我试图做的是通过 n ( https://www.npmjs.com/package/n)降级到 Node v.5 - 它有效。然后删除所有node_modules文件夹,然后执行

npm info graceful-fs -v
3.3.6

ok, lets upgrade or remove and install new:

好的,让我们升级或删除并安装新的:

npm i graceful-fs@latest
npm i [email protected]
sudo npm i [email protected] -g

all results in

所有结果都在

npm info graceful-fs -v
3.3.6

So now I am currenlty stuck with graceful-fs 3.3.6or even worse in some modules dependances, like

所以现在我在某些模块依赖项中坚持使用优雅的 fs 3.3.6甚至更糟,比如

$ angular2-seed
$ npm install

//other lines..
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before 
will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 
as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.

What could be the strategy here:

这里的策略是什么:

  • Manually patch all the deps that contain graceful-fs < 4.0.0?
  • There's some global switch to use specific package version?
  • Reinstall everything?
  • 手动修补所有包含 graceful-fs < 4.0.0 的 deps?
  • 有一些全局开关可以使用特定的包版本吗?
  • 重新安装一切?

回答by Asimov

I had this problem and I was able to fix this by updating npm

我遇到了这个问题,我能够通过更新来解决这个问题 npm

sudo npm update -g npm

Before the update, the result of npm info graceful-fs | grep 'version:'was:

更新前的结果npm info graceful-fs | grep 'version:'是:

version: '3.3.12'

After the update the result is:

更新后的结果是:

version: '3.9.3'

回答by analog-nico

Type npm list graceful-fsand you will see which versions of graceful-fs are currently installed.

键入npm list graceful-fs,您将看到当前安装了哪些版本的优雅-fs。

In my case I got:

就我而言,我得到了:

npm list graceful-fs

@request/[email protected] /projects/request/promise-core
+-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   | `-- [email protected]
|   |   `-- [email protected]
|   |     `-- [email protected]
|   |       `-- [email protected]        <==== !!!
|   `-- [email protected] 
`-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  |     `-- [email protected]
  |       `-- [email protected] 
  `-- [email protected]
    `-- [email protected]
      `-- [email protected]

As you can see gulpdeep down depends on a very old version. Unfortunately, I can't update that myself using npm update graceful-fs. gulpwould need to update their dependencies. So if you have a case like this you are out of luck. But you may open an issue for the project with the old dependency - i.e. gulp.

正如您所看到的gulp,它依赖于一个非常旧的版本。不幸的是,我无法使用npm update graceful-fs. gulp需要更新它们的依赖项。因此,如果您遇到这样的情况,那您就不走运了。但是您可能会为具有旧依赖项的项目打开一个问题 - 即gulp.

回答by Hamza Erbay

Solved this bug with reinstall gulp

通过重新安装 gulp 解决了这个错误

npm uninstall gulp
npm install gulp

回答by David

Deleting node_modules folder contents and running

删除 node_modules 文件夹内容并运行

npm install bower
npm install

solved the problem for me!

为我解决了问题!

回答by serv-inc

As described here, you can also attempt the command

如上所述在这里,你还可以尝试的命令

npm cache clean

That fixed it for me, after the other steps had not fully yielded results (other than updating everything).

在其他步骤没有完全产生结果之后(除了更新所有内容),这对我来说是固定的。

回答by Yohio

Just to point out that cordova brings in it's own npm with the graceful-fs dependency, so if you use Cordova make sure that it is the latest so you get the latest graceful-fs from that as well.

只是要指出,cordova 引入了它自己的 npm 和优雅的 fs 依赖项,所以如果您使用 Cordova,请确保它是最新的,这样您也可以从中获得最新的优雅-fs。

回答by szuuuken

I was able to fix it by:

我能够通过以下方式修复它:

  1. updating by package.json
  2. deleting the node_modules folder
  3. executing npm install
  1. 更新者 package.json
  2. 删除 node_modules 文件夹
  3. 执行 npm install

回答by Magnus Ingwersen

In the case of my Cordova-project, uninstalling and installing cordova -g fixed the problem for me.

对于我的 Cordova 项目,卸载和安装 cordova -g 为我解决了这个问题。

npm uninstall -g cordova
npm install -g cordova

回答by David H

The report says : a file is missing in ... vendor/win32-x64-48/binding.node

报告说:... vendor/win32-x64-48/binding.node 中缺少文件

I looked for the binding.node file and I find it in...

我寻找了 binding.node 文件,我在...

https://github.com/sass/node-sass-binaries

https://github.com/sass/node-sass-binaries

Copy the correct file with the name binding.node and it works.

复制名为 binding.node 的正确文件,它可以工作。

回答by Aziz Alto

Or try to update node:

或尝试更新node

brew upgrade node

If it is installed with brew(like in my case). sudo npm update -g npmdid not solve the "same" problem for me.

如果它安装了brew(就像我的情况)。sudo npm update -g npm没有为我解决“相同”的问题。