【问题标题】:npm install not working, module not found, tried seemingly everythingnpm install 不工作,找不到模块,尝试了一切
【发布时间】:2020-09-22 18:37:30
【问题描述】:

到目前为止,我在安装模块方面没有遇到任何问题,但我不确定出了什么问题,因为我根本没有改变我的工作流程。

我跑了:

npm i --save mariadb

在我的 Node 项目的根目录中。然后我导入了这个模块:

const mariadb = require("mariadb")

但是,当我尝试跑步时,我得到了

Error: Cannot find module 'mariadb'

查看 node_modules,mariadb 确实在里面,但是在 package.json 中查看,mariadb 没有在依赖项中列出。然后我尝试运行

npm install --save mariadb

在 src 目录下效果相同。然后尝试了

npm install -g mariadb

同样的效果。然后尝试了

rm -rf node_modules
npm install

同样的效果,我也得到这个错误(我认为它一定是相关的):

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/codyray/github.com/cody-a-ray/neighbors/client/node_modules/fsevents
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 

> core-js@2.6.11 postinstall /Users/codyray/github.com/cody-a-ray/neighbors/client/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

此外,在最后一条命令之后,每个 package.json 文件都有以下错误:

Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': getaddrinfo ENOTFOUND schemastore.azurewebsites.net.

我不知道这意味着什么。显得非常神秘。 然后我尝试手动将 mariadb 添加到我的 package.json 并运行

npm install --save

再一次,没有效果。

上帝帮助我

【问题讨论】:

  • 您是否配置了任何防火墙或 VPN,或者您的网络最近是否发生了任何变化?另一件事是你是否用其他包(你没有)测试它,看看它是否是 mariadb 唯一的问题?你使用的是什么版本的 npm/node?有考虑更新吗?
  • 我实际上是在使用VPN,然后意识到这可能是一个问题,所以我断开了我的VPN,删除了node_modules,重新安装了所有东西,同样的错误发生了。我升级了节点。看起来这不仅仅是 mariadb 的问题,因为我现在无法使用任何新模块。我已经在使用的所有模块似乎仍在工作。
  • 你试过了吗:medium.com/flawless-app-stories/…?看起来对我很有说服力。虽然我不使用 mac,所以我无法测试这个解决方案。
  • 因此,如果您在使用新模块时也遇到问题,我肯定怀疑是某种网络问题。您提到您禁用了 VPN 并且仍然无法正常工作,您正在使用的网络上有任何代理吗?你有没有办法用不同的连接来测试它(也许用手机网络代替)

标签: mysql node.js json npm mariadb


【解决方案1】:

也许你应该试试

npm install mariadb --save

我发现您的顺序有误,有关更多信息,请在您的控制台上运行此命令:

npm help install

【讨论】:

  • 试过这个效果一样
猜你喜欢
  • 2015-12-16
  • 2016-02-25
  • 2015-02-26
  • 2022-10-23
  • 2019-05-04
  • 2016-12-23
  • 2017-01-12
  • 2017-02-17
相关资源
最近更新 更多