我使用npm install -g gulp
[npm WARN deprecation warnings redacted]
/usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp/bin/gulp.js
/usr/local/lib
└── gulp@3.9.1
当我尝试运行gulp命令时,我得到:
gulp
[19:42:23] Local gulp not found in ~/javascript
[19:42:23] Try running: npm install gulp
但是当我在全局安装另一个npm包时,它可以工作。例如,当我像这样安装create-react-app
时:
npm install -g create-react-app
/usr/local/bin/create-react-app -> /usr/local/lib/node_modules/create-react-app/index.js
/usr/local/lib
└─┬ create-react-app@0.2.0
├─┬ chalk@1.1.3
│ ├── ansi-styles@2.2.1
│ ├── escape-string-regexp@1.0.5
│ ├─┬ has-ansi@2.0.0
│ │ └── ansi-regex@2.0.0
│ ├── strip-ansi@3.0.1
│ └── supports-color@2.0.0
├─┬ cross-spawn@4.0.0
│ ├─┬ lru-cache@4.0.1
│ │ ├── pseudomap@1.0.2
│ │ └── yallist@2.0.0
│ └─┬ which@1.2.10
│ └── isexe@1.1.2
├── minimist@1.2.0
└── semver@5.3.0
在安装后运行命令时,它可以工作:
create-react-app
Usage: create-react-app <project-directory> [--verbose]
有什么理由说gulp会搞砸了吗?
答案 0 :(得分:1)
您必须安装Gulp CLI才能使命令行正常工作npm install -g gulp-cli