gulp 未找到命令 (Mac OS)

gulp command not found (Mac OS)

我一直在尝试使用 yo、grunt 和 generator-gulp-angular 设置一个 angular js 项目。虽然我安装了所有软件包,但找不到 gulp 命令,但是如果我进入 node_modules.

就可以了

此代码将解释我的问题:

$ npm -v
# 2.5.1
$ npm install -g yo
$ npm install -g generator-gulp-angular
$ mkdir client && cd $_
$ yo gulp-angular ng_demo
$ gulp serve
# command not found
$ node_modules/gulp/bin/gulp.js serve
# works

我正在使用 zsh。可能出了什么问题?

检查您是否全局安装了 gulp:

npm install -g gulp

另一个想法是将 scripts 添加到您的 package.json 文件中:

{
  "name": "testing-app",
  "version": "0.9",
  "scripts": {
    "gulp": "gulp",
    "serve": "gulp serve"
  }
}

然后使用npm run serve...