惨案
我一般运用敕令装置express。
$ npm install -g express-generator
然后bash就提醒装置胜利
/Users/majialun/.npm-global/bin/express -> /Users/majialun/.npm-global/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator@4.16.1
updated 1 package in 2.123s
然后运转 express
,按原理这个时刻应当让我建立项目了,然则体系提醒:
bash: express: command not found
实在不光是express,我本身写的剧本,也涌现这个题目,全局装置胜利,然则,经由过程bash就是挪用不出来。
侦察
先看看全局有哪些path变量
$ echo $PATH
然后就涌现了许多
/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin:/Users/majialun/.npm-global/bin/express:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin:/Users/majialun/.npm-global/bin/express:/Users/majialun/.rvm/bin:/Users/majialun/.npm-global/bin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin:/Users/majialun/.npm-global/bin/express:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/majialun/.rvm/gems/ruby-2.4.1/bin:/Users/majialun/.rvm/gems/ruby-2.4.1@global/bin:/Users/majialun/.rvm/rubies/ruby-2.4.1/bin:/Users/majialun/.rvm/bin:/Users/majialun/Documents/flutter/flutter/bin
这个时刻我们发明太多了,然则不要慌,适才装置Express的时刻,有一个提醒显现了npm的全局剧本挂在哪一个path下。
再看看装置胜利的提醒:
/Users/majialun/.npm-global/bin/express -> /Users/majialun/.npm-global/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator@4.16.1
updated 1 package in 2.123s
我们能够看到,剧本装置在/Users/majialun/.npm-global/bin
,这个目次里就是悉数的全局剧本,注重是bin目次,express只是这个目次下的一个罢了。
然后我们细致在全局的path里找,发明并不存在这个途径……我也不知道我是怎样把途径搞没的,我在公司的Macbook Pro一切一般,然则随身带的Macbook就缺失途径。
破案
我们直接去根目次(/Users/majialun/
)下,显现隐蔽文件后,看看有无.bash_profile
,没有就新建一个,有就直接修正,增加进去一个途径:
export PATH=$PATH:/Users/majialun/.npm-global/bin:$PATH
注重这个途径是从上面复制下来的,每个人的不一样,总之从装置胜利的提醒里,复制到/bin这里完毕就能够了。
好了以后,在终端里打source
,然后把.bash_profile
拖进来,就有了:
$ source /Users/majialun/.bash_profile
实行一下然后重启终端,跑起来碰运气:
majialun$ express
warning: the default view engine will not be jade in future releases
warning: use `--view=jade' or `--help' for additional options
destination is not empty, continue? [y/N]
没有not found 的报错,题目解决。