I wrote my first node.js app, but it can\'t find express library:
C:\\ChatServer\\Server>node server.js
module.js:340
throw err;
^
Error: C
I hit the same problem. I had express installed globally at /usr/local/bin/. When I do 'npm install', express was not created in node_modules of local directory.
I had the same error following the example on this book: "Kubernetes Up & Running".
I see many answers suggesting to install express "by hand" but I'm not convinced is the best solution.
Because we are using package.json (I can see it in the logs) and the right way to build the app is running npm install
, I added the express dependency in the package.json file.
"dependencies": {
"express": "^4.17.1"
}
I get the current version with npm search express
.
Check if you are not install express
module, use this command:
npm install express
and if your node_modules
directory is in another place, set NODE_PATH
envirnment variable:
set NODE_PATH=your\directory\to\node_modules;%NODE_PATH%
create one folder in your harddisk e.g sample1 and go to command prompt type :cd and gives the path of sample1 folder and then install all modules...
npm install express
npm install jade
npm install socket.io
and then whatever you are creating application save in sample1 folder
try it...
This worked for me on MacOS X Sierra
In your case your express
module is installed at C:\Users\Dmitry\AppData\Roaming\npm\node_modules\express
, but you need to get this module in to your project directory. So you should copy the file the express
module folders from C:\Users\Dmitry\AppData\Roaming\npm\node_modules\
to your project directory as : C:\ChatServer\Server\node_modules
. If you do not have a folder named 'node_modules' in your project folder, then create it first and paste those files into this folder. This method worked for me on my windows pc. Restart your node server and once again run the command node C:\ChatServer\Server>node server.js
. It should work now !!!!