I ran the following from the npm/node_modules dir (OSX):
npm install express
and I see the express dir in the node_modules dir.
I then try and launch my connectionCounter.js file, but get the following error:
Cannot find module 'express'
I've tried executing "node connectionCounter.js" from several places (npm dir, express dir, dir connectionCounter.js is in), to see if that will work -- but no luck.
Does anyone know where I should be running the node command from?
Thanks.
You use
npm install express
in the root folder of your project. If you want to install it globally, use
npm install -g express
"I ran the following from the npm/node_modules dir "
I think this is your problem. Run that command in the directory connectionCounter.js is in. Your directory structure should look like this after you run that command:
dir/
|-connectionCounter.js
|-node_modules/
|-express/
|-all the stuff in express
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.