可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
After installing gulp.js via NPM i receive a no command 'gulp' found
error when running the gulp
command from the same directory it was installed into.
When looking under the node_modules/.bin/
directory i can see the gulp
executable there.
Is there something wrong with my NPM installation?
回答1:
That's perfectly normal. If you want gulp-cli
available on the command line, you need to install it globally.
npm install --global gulp-cli
See the install instruction.
Also, node_modules/.bin/
isn't in your $PATH
. But it is automatically added by npm when running npm scripts (see this blog post for reference).
So you could add scripts
to your package.json
file:
{ "name": "your-app", "version": "0.0.1", "scripts": { "gulp": "gulp", "minify": "gulp minify" } }
You could then run npm run gulp
or npm run minify
to launch gulp tasks.
回答2:
I actually have the same issue.
This link is probably my best guess:
nodejs vs node on ubuntu 12.04
I did that to resolve my problem:
sudo apt-get --purge remove node sudo apt-get --purge remove nodejs sudo apt-get install nodejs sudo ln -s /usr/bin/nodejs /usr/bin/node
回答3:
I solved the issue without reinstalling node using the commands below:
$ npm uninstall --global gulp gulp-cli $ rm /usr/local/share/man/man1/gulp.1 $ npm install --global gulp-cli
回答4:
I solved the issue removing gulp and installing gulp-cli again:
rm /usr/local/bin/gulp npm install -g gulp-cli
回答5:
Installing on a Mac - Sierra - After numerous failed attempts to install and run gulp globally via the command line using several different instructions I found I added this to my path and it worked:
export PATH=/usr/local/Cellar/node/7.6.0/libexec/npm/bin/:$PATH
I got that path from the text output when installing gulp.