node.js: cannot find module 'request'

后端 未结 8 1794
再見小時候
再見小時候 2020-12-07 14:29

I installed request module, and getting the error:

module.js:340
    throw err;
          ^
Error: Cannot find module \'request\'

i\'ve read

8条回答
  •  囚心锁ツ
    2020-12-07 14:40

    I was running into the same problem, here is how I got it working..

    open terminal:

    mkdir testExpress
    cd testExpress
    npm install request
    

    or

    sudo npm install -g request // If you would like to globally install.
    

    now don't use

    node app.js or node test.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

    npm start
    

    You should see this..

    testExpress@0.0.0 start /Users/{username}/testExpress
    node ./bin/www
    

    Open your web browser and check for localhost:3000

    You should see Express install (Welcome to Express)

提交回复
热议问题