I installed request module, and getting the error:
module.js:340
throw err;
^
Error: Cannot find module 'request'
i've read all the posts about this error, and understand that this is because module requests is not globally found, but i've already tried the 2 suggestions
npm install request -g
should this install it in /usr/loca/bin ? because i don't see it there.
and
sudo npm link
/usr/local/lib/node_modules/request -> /Users/soulsonic/dev/sandbox/node_test/request
i restarted terminal after each command, but keep getting the cannot find module error.
update
there must have been some sort of conflict in my initial directory, because "npm install request" was not adding "request" under node_modules (there 10 others in there) .. after switching to a new directory it just worked.
if i run it with -g switch, i do see it bing installed to /usr/local/lib/node_modules/request.
it seems that i just need to update my profile so that above path is automatically added.
I have met the same problem as I install it globally, then I try to install it locally, and it work.
Go to directory of your project
Make this directory a root of your project (this will create a default
package.json
file)Install required npm module and save it as a project dependency (it will appear in
package.json
)Create a
test.js
file in project directory with code from package exampleYour project directory should look like this
Now just run node inside your project directory
I was running into the same problem, here is how I got it working..
open terminal:
or
now don't use
node
app.js
or nodetest.js
, you will run into this problem doing so. You can also print the problem that is being cause by using this command.."node -p app.js"
The above command to start nodeJs has been deprecated. Instead use
You should see this..
Open your web browser and check for localhost:3000
You should see Express install (Welcome to Express)
if some module you cant find, try with Static URI, for example:
This example, run on Ubuntu Gnome 16.04 of 64 bits, node -v: v4.2.6, npm: 3.5.2 Refer to: Blog of Ben Nadel
I had same problem, for me
npm install request --save
solved the problem. Hope it helps.You should simply install
request
locally within your project.Just
cd
to the folder containing your js file and run