node.js 节点错误找不到已安装的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9704660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
node error cannot find module already installed
提问by Thetsu
[root@zexu websocket_start]# npm ls -g installed npm WARN ls doesn't take positional args. Try the 'search' command npm WARN [email protected] package.json: bugs['web'] should probably be bugs['url'] /usr/lib ├─┬ [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] [root@zexu websocket_start]# npm ls installed npm WARN ls doesn't take positional args. Try the 'search' command /home/qonco/workspace/JS/websocket_start (empty) [root@zexu websocket_start]# node > require("websocket-server"); Error: Cannot find module 'websocket-server' at Function._resolveFilename (module.js:332:11) at Function._load (module.js:279:25) at Module.require (module.js:354:17) at require (module.js:370:17) at repl:1:1 at REPLServer.eval (repl.js:80:21) at repl.js:190:20 at REPLServer.eval (repl.js:87:5) at Interface. (repl.js:182:12) at Interface.emit (events.js:67:17) >
回答by Toni
you have installed the module global go to your app and try this to link the global to your application folder
您已经安装了模块 global 转到您的应用程序并尝试将全局链接到您的应用程序文件夹
sudo npm link <MODULeNAME>
回答by Javo
Have you installed the module with the -g option? I think that not every module is meant to be installed globally, instead, try installing it locally for the project you are creating (npm install), and check if the error persists.
您是否使用 -g 选项安装了模块?我认为并不是每个模块都应该全局安装,而是尝试为您正在创建的项目(npm install)在本地安装它,并检查错误是否仍然存在。

