Error: Cannot find module 'request' [SOLVED]

nodejs

#1

Hi guys,

Just started a new private workspace to run stripe payment for my app.

I installed node.js (npm install) into my server-side directory, and uploaded my server-side files to c9.

When I run the server.js file, I get this error

Is this because when I installed node.js, some modules where not installed or am I doing something wrong on C9?

Any help would be much appreciated.
Love c9!

David


#2

You :slight_smile: You should be able to run npm install and fix it, if you have a package.json file already configured. Otherwise, run npm install request or something like that (I can’t remember if that’s the exact name for the package or if it’s something special).


#3

Hi Brady,

It threw a number of errors when I used npm install, it allowed me to install > npm-install request.

It then needed> “express” “body-parser” modules as well.

EDIT: After installing the modules I received this error:

I do have a package.json file already configured in there.

I will delete the folder, re-install node, upload and see what happens this time round.

Stay tuned! :slight_smile:


#4

You may already be running it in another terminal tab. You can use netstat -tulpn to find any processes running on that port and use kill to kill them. See the link in the help popup in the top right of your screenshot too, that will help you solve this issue.


#5

Hi guys,

Thank you both for your help! It was a combination of both your suggestions that solved this issue.

  1. On my computer, I cd to the modules folder, I installed the module “request” via the CMD/Terminal npm install request.

  2. Reuploaded the files to 9cloud.

  3. Followed the instructions on: https://docs.c9.io/docs/common-errors
    (I did have other services running)

4.Went to server.js and clicked Run.

  1. Result:

You’re very quick to respond and help, I love it and I love 9cloud. Going to Upgrade my account now.

Thanks

David


#6

Made this account to just say thank you so much!! This solved the same problem I had using node js on my mac. Been trying to fix it for the last 4 hours and had no idea what went wrong!