Node.js Error: Cannot find module express?

Node.js Error: Cannot find module express?

Asked on October 24, 2018 in node.js.
Add Comment


  • 4 Answer(s)

    Use this to install express module:

    npm install express
    
    

    set NODE_PATH environment to variable,  if our node_modules directory is in another place:

    set NODE_PATH=your\directory\to\node_modules;%NODE_PATH%
    
    

     

     

    Answered on October 24, 2018.
    Add Comment

    We need to install Express locally into the context of our application (node_modules folder):

    $ npm install express
    

    That the applications always look in their local context for any dependencies. The global installation is only for setting up system-wide available binaries, such as unit test runners or bootstrappers or things like that.

    With Express, when you install it globally, you get an express binary that can bootstrap an application for you. For more information, type

    $ express --help
    

    we need to install it without

    -g

     

    Answered on October 24, 2018.
    Add Comment

    installed express locally with –save option :

    $ npm install express --save
    
    

    the above code can be used to solve the error

    Answered on October 24, 2018.
    Add Comment

    You need to install Express locally into the context of your application (node_modules folder):

    $ npm install express

    The reason for this is that applications always look in their local context for any dependencies. The global installation is only for setting up system-wide available binaries, such as unit test runners or bootstrappers or things like that.

    With Express, when you install it globally, you get an express binary that can bootstrap an application for you. For more information, type

    $ express --help
    Answered on February 21, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.