Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

javascript - 安装Gulp后:“没有命令'gulp'发现”(After installation of Gulp: “no command 'gulp' found”)

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.(安装完成后gulp.js通过NPM,我收到一个no command 'gulp' found运行时错误gulp从它被安装到同一个目录的命令。)

When looking under the node_modules/.bin/ directory, I can see the gulp executable there.(当水下看node_modules/.bin/目录,我可以看到gulp可执行那里。)

Is there something wrong with my npm installation?(我的npm安装有问题吗?)

  ask by AndrewMcLagan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That's perfectly normal.(那是完全正常的。)

If you want gulp-cli available on the command line, you need to install it globally.(如果您希望在命令行上使用gulp-cli ,则需要全局安装它。)
npm install --global gulp-cli

See the install instruction .(请参阅安装说明 。)

Also, node_modules/.bin/ isn't in your $PATH .(此外, node_modules/.bin/不在$PATH 。)

But it is automatically added by npm when running npm scripts (see this blog post for reference ).(但是在运行npm脚本时它会被npm自动添加(请参阅此博客文章以供参考 )。)

So you could add scripts to your package.json file:(所以你可以在你的package.json文件中添加scripts :)

{
    "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.(然后你可以运行npm run gulpnpm run minify来启动gulp任务。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...