【问题标题】:NPM throwing missing dependency but it exists?NPM 抛出缺少的依赖,但它存在吗?
【发布时间】:2020-04-17 01:24:05
【问题描述】:

我遇到了一个问题,我已经尝试了一个小时左右,但我似乎无法弄清楚。

当我在我的 app.js 文件中包含谷歌地图然后重新加载时,我从 npm 收到以下错误:

ERROR  Failed to compile with 14 errors                                                                                                                                                                                      
5:05:10 PM
This dependency was not found:

* fs in ./node_modules/request/lib/har.js

To install it, you can run: npm install --save fs


This relative module was not found:

* ./config/constants in ./node_modules/googlemaps/lib/index.js, ./node_modules/googlemaps/lib/placeSearchText.js and 11 others  Asset     Size

但是当我运行 npm install --save fs 它运行并完成但我仍然得到同样的错误。

任何帮助将不胜感激

npm 版本:5.3.0

谷歌地图:最新

节点 Js:6.11.1

【问题讨论】:

  • fs 不是 Node 标准的一部分吗?你用的是什么版本的 NPM 和 Node?根据 NPM,fs 不再是一个包:npmjs.com/package/fs
  • 这很奇怪。我想知道为什么谷歌地图需要它作为依赖项?
  • 编辑您的问题添加更多信息:NPM 的版本、Node 的版本、Google 地图的版本...

标签: php node.js laravel npm


【解决方案1】:

对不起,我还不能添加 cmets,但尝试像这样卸载软件包:
npm uninstall <package name> 然后重新安装它:npm install <package name>

有时它会起作用。

【讨论】:

  • 太糟糕了,希望你能找到答案。 @Dazeh
  • 1: rm -rf node_modules 2. npm cache clear 3. npm install 祝你好运!有时工作
【解决方案2】:

问题似乎是 request 包已被弃用,fsrequest 的依赖项,因此 webpack 不再编译它。 github问题在这里:https://github.com/request/request/issues/3142

看起来临时修复是在 webpack 配置文件中添加以下内容,但我不确定在哪里可以找到它

node: {
  fs: 'empty'
}

【讨论】:

    猜你喜欢
    • 2020-03-17
    • 1970-01-01
    • 2021-11-23
    • 2017-07-10
    • 2017-06-16
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    相关资源
    最近更新 更多