【问题标题】:express: command not found error快递:找不到命令错误
【发布时间】:2018-06-08 00:56:33
【问题描述】:

我知道这个话题有很多答案,但仍然没有解决我的问题。

我的设置:

  • Mac 操作系统
  • Node.js v8.11.2
  • npm v5.6.0

我试过这个:

  • sudo npm install -g express-generator 来自here
  • reinstall node.js 来自here
  • npm init 之后快速安装。 (但当我完成this tutorial 时,只会生成“package.json”)

当我安装 express 和 express-generator 时,

$ npm install -g express
+ express@4.16.3
updated 1 package in 1.499s

$ npm install -g express-generator
/Users/soodiamond/.npm-global/bin/express -> 
/Users/soodiamond/.npm-global/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator@4.16.0
updated 1 package in 0.925s

还是找不到 express 命令

$ express myapp
-bash: express: command not found

【问题讨论】:

    标签: node.js express terminal installation


    【解决方案1】:

    模块express在package.json中没有bin,所以你不能调用它。 (npm 不要在 bin 文件夹中创建文件 express

    当你运行时:sudo npm install -g express-generator,

    【讨论】:

    • 谢谢@kỉaT 我试着打电话给express-generator,但错误是一样的。 -bash: express-generator: commant not found
    • 对不起,安装express-generator时可以拨打express。你应该检查 bin 文件夹(我不使用 Mac OS,所以我不知道 bin 文件夹的路径)。
    • 是的,这是我的路径问题。我发现 express 文件夹路径未在 $PATH 中注册。当我添加它时,它就可以工作了。
    【解决方案2】:

    我在第一次安装 express 时遇到了完全相同的问题。可能@4.16 版本有一些问题。
    试试:
    sudo npm install -g express@4.13.1

    为我工作!

    【讨论】:

      猜你喜欢
      • 2014-12-17
      • 2014-05-24
      • 1970-01-01
      • 2014-05-25
      • 2016-03-24
      • 2016-07-12
      • 2016-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多