express command not found in bash after installing it with npm

后端 未结 7 1309
自闭症患者
自闭症患者 2020-12-23 11:53

just installed new ubuntu vm to test around with node installed things in this order:

node
mongodb-server
npm
express
mongoose

now, trying

相关标签:
7条回答
  • 2020-12-23 12:48

    EDIT 2017-06-29: this answer is 6+ years old, but still gets votes/traffic. Instead (for any new users with problems) I'd trust both NODE_PATH official doc and its corresponding bit about REPL usage before this answer.

    Quite similar to this issue, node was not finding my global express install, so a require('express') statement would fail.

    What fixed this for me, when a global install wasn't being picked up by node was making sure NODE_PATH env. variable was is set correctly. On Ubuntu 11.04, with node version 0.5.0-pre, the paths me were:

    NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node
    

    So, to clarify you might want to export the above env. variable, or you can just test the above values out by doing:

    NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node node ./you_app.js
    
    0 讨论(0)
提交回复
热议问题