[英]Cannot find module (nodejs)
模塊: getmac https://www.npmjs.org/package/getmac
背景故事:我以前使用過模塊getmac,它的工作原理很吸引人。 不久前,我將nodejs更新為0.11。 今天,我嘗試再次使用它。 我安裝了它(npm install get mac)嘗試使用。 不。 “找不到模塊”。 我在node_modules中看到getmac文件夾。 Npm ls
顯示:
├─┬ getmac@1.0.6
│ └─┬ extract-opts@2.2.0
│ └── typechecker@2.0.8
我正在使用20多個其他模塊,沒有任何問題。
操作系統: Windows 7 32bit,管理員帳戶
我如何測試它是否有效:我的項目可能是一個問題:
npm install getmac
test.js
: require('getmac');
nodejs test.js
每次結果都是相同的:
module.js:340 throw err; ^ Error: Cannot find module 'getmac' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (C:\\Users\\Nfq\\testo\\test.js:1:63) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10)
其他模塊工作正常
我試過的
require('./node_modules/getmac')
program files/nodejs/node_modules
%appdata%/npm/
program files/nodejs/node_modules
sublimetext2錯誤:
[8036:1014/141615:INFO:CONSOLE(293)] "{"stack":"Error: Cannot find module 'getmac'\n at Function.Module._resolveFilename (module.js:334:15)\n
"Uncaught Error: Cannot find module 'getmac'", source: module.js (336)
文件夾node_modules / getmac的文件結構:
C:\Users\Nfq\testo\node_modules\getmac
- .npmignore
- History.md
- LICENSE.md
- package.json
- README.md
-
+¦¦¦bin
- getmac-node
-
L¦¦¦node_modules
L¦¦¦extract-opts
- .npmignore
- example.js
- LICENSE.md
- package.json
- README.md
-
+¦¦¦node_modules
- L¦¦¦typechecker
- - .npmignore
- - cyclic.js
- - History.md
- - LICENSE.md
- - package.json
- - README.md
- -
- L¦¦¦out
- L¦¦¦lib
- typechecker.js
-
L¦¦¦out
L¦¦¦lib
extract-opts.js
請幫我。
刪除node_modules
文件夾,運行npm cache clean
然后重新安裝軟件包npm install
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.