简体   繁体   English

节点找不到IP模块

[英]Node can't find IP module

I am trying to use the IP module in a Node program.我正在尝试在 Node 程序中使用IP 模块 However, whenever I try to add it in using const ip = require("ip") , I get the following error:但是,每当我尝试使用const ip = require("ip")添加它时,都会出现以下错误:

internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module 'ip'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/fin444/Desktop/node/app.js:1:207)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Why is this happening?为什么会这样? I have installed and reinstalled the latest version of IP several times globally on my computer, and all other Node modules work fine.我已经在我的计算机上多次全局安装并重新安装了最新版本的 IP,并且所有其他 Node 模块都可以正常工作。

Try this:尝试这个:

  npm uninstall ip -g --save

Then:然后:

  npm install ip -g --save

I don't know if --save is required anymore but I have had the issue that without this flag the module could not be found.我不知道是否不再需要 --save 但我遇到了没有这个标志就找不到模块的问题。 Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM