Express command not found

前端 未结 4 1795
执念已碎
执念已碎 2020-11-28 19:05

For some reason after installing Express globally on my machine with npm install -g express if I cd into a directory and try to run express I get t

相关标签:
4条回答
  • 2020-11-28 19:41

    I was having this challenge for a number of days. After deep search, I learned that one has to read every available resource especially from the parent source [in this case EXPRESSJS.COM]. Here is a quick fix.

    Beginning with version 4.0+ you don't necessarily need to install express-generator if you are running Node 8.2+. Simply run

    npx express-generator
    

    The express-generator will run just the way it runs when you run:express

    For more details see Getting Started

    Happy reading and research hours.

    0 讨论(0)
  • 2020-11-28 19:45

    You need to run:

    npm install -gd express-generator
    

    The original express with cli, now the cli split into separate express-generator package. Originally generated by the project is running express node app.js, because httpserver relevant code in app.js, and now this part of the code to the project directory bin/www below, app.js retain only achieve app logic code, you need to run the bin/www. Just a very simple application and refinement package dependency version changes.

    0 讨论(0)
  • 2020-11-28 19:49

    With the release of Express 4.0.0 it looks like you need to do sudo npm install -g express-generator.

    0 讨论(0)
  • 2020-11-28 19:50

    I have been recently trying to install express-generator , however it would give out ,

    $ zsh : command not found : express
    
    

    It was after i did

    $ sudo npm install -g express
    $ sudo npm install -g express-generator
    
    

    But then , i saw the console log of the npm install commnand

    /usr/local/Cellar/node/13.1.0/bin/express -> /usr/local/Cellar/node/13.1.0/lib/node_modules/express-generator/bin/express-cli.js
    
    

    which gave a hint that the executable express is in the bin folder.

    So the solution is : Open up ~/.zshrc or ~/.bashrc and export the path as follows:

    export PATH=/usr/local/Cellar/node/13.1.0/bin:$PATH
    

    It works now.

    0 讨论(0)
提交回复
热议问题