2013-10-17 287 views
0

我使用npm安装了tarfstream,之后我运行了一些命令。输出是:NPM require('tar')找不到模块错误

您的环境已设置为使用Node.js 0.10.18(ia32)和npm。

C:\Users\abc>npm --version 
1.3.8 

C:\Users\abc>npm list 
C:\Users\abc 
├── [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] 
│ │ ├── [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] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └── [email protected] 


C:\Users\abc>node --version 
v0.10.18 

现在在运行的node.js当我这样做require('tar')我得到

> require('fstream') 
Error: Cannot find module 'fstream' 
    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 repl:1:2 
    at REPLServer.self.eval (repl.js:110:21) 
    at Interface.<anonymous> (repl.js:239:12) 
    at Interface.EventEmitter.emit (events.js:95:17) 
    at Interface._onLine (readline.js:202:10) 
    at Interface._line (readline.js:531:8) 
> require('tar') 
Error: Cannot find module 'tar' 
    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 repl:1:2 
    at REPLServer.self.eval (repl.js:110:21) 
    at Interface.<anonymous> (repl.js:239:12) 
    at Interface.EventEmitter.emit (events.js:95:17) 
    at Interface._onLine (readline.js:202:10) 
    at Interface._line (readline.js:531:8) 

我应该怎么办?

回答

1

该错误表示您正在尝试将这些模块设置为require()这些目录中的模块永远不会解析为您显示的目录,即C:\Users\abc\node_modules

如果你是一个目录,如C:\Users\user2,该模块将永远不会解决,因为模块会以这种方式被检查:

C:\Users\user2\node_modules 
C:\Users\node_modules 
C:\node_modules 

要解决此问题,移动到一个目录是一个孩子与node_modules文件夹共享父目录的目录,或使用-g标志全局安装模块。

+0

我不知道,我甚至用-g标志试过。但似乎没有任何工作。然后我重新启动,它的工作。我不确定。可能是我半睡着了。 –