gulp 命令没有找到解决办法

I recently wanted to install a new NPM module (that is Gulp). I followed the getting started guide and ran the needed command but it didn’t worked and I felt desperate… but I finally found the solution!

o give you a little context: I ran the following command for installing Gulp (a node package module) globally: npm install -g gulp

The installation succeed but when I ran this gulp command in the command line I got a "gulp: command not found" error. It appeared that it installed “Gulp” in my local folder that is /Users/YOURUSERNAME/node_modules and not in the global NPM folder.

You can check this by running this command: npm root or npm root -g, which was returning my personal directory /Users/YOURUSERNAME/node_modules and not the expected /usr/local/lib/node_modules.

After some trial & error, I finally found the solution. You have to change the “npm config prefix” like so: npm config set prefix /usr/local

Then when I re-ran npm root -g, I got the correct root folder: /usr/local/lib/node_modules

When I reinstalled Gulp globally (with the -g param) it finally worked and appeared that it was now correctly installed in the global NPM folder. Yeay!

 

转载于:https://my.oschina.net/swmhxhs/blog/1511685

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值