Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node error cannot find module already installed

[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)
> 

like image 590
Thetsu Avatar asked Mar 14 '12 15:03

Thetsu


People also ask

How do I resolve node modules error?

To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.

Can not find module node path?

To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm i -D @types/node . You can then import path with the following line of code import * as path from 'path' .

What does Cannot find module mean?

The "Cannot find module" error in Node. js occurs for multiple reasons: Forgetting to install a third-party package with npm i somePackage . Pointing the node command to a file that doesn't exist. Having an outdated version of the package, or an IDE or development server glitch.

Can not find module npm?

Set the Windows environment variable for NODE_PATH. This path is where your packages are installed. It's probably something likeNODE_PATH = C:\Users\user\node_modules or C:\Users\user\AppData\Roaming\npm\node_modules. Start a new cmd console and npm should work fine.


2 Answers

you have installed the module global go to your app and try this to link the global to your application folder

   sudo npm link <MODULeNAME> 
like image 57
Toni Avatar answered Oct 24 '22 02:10

Toni


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.

like image 26
Javo Avatar answered Oct 24 '22 01:10

Javo