找不到npx,以为它在PATH中

时间:2018-09-18 00:36:42

标签: javascript node.js npm

我正在为React教程设置本地环境,但是遇到了一些问题。

我拥有哪个版本的节点?

$ node -v
v10.10.0

设置教程环境

$ npm install -g create-react-app
/opt/nodejs/bin/create-react-app -> /opt/nodejs/lib/node_modules/create-react-app/index.js
+ create-react-app@1.5.2
added 67 packages from 20 contributors in 9.879s

执行教程设置说明:

$ npx create-react-app my-app
-bash: npx: command not found

什么?! npx丢失了吗?

$ npx 
-bash: npx: command not found

嗯。使用此解决方案(npx command not working)

$ npm i -g npx
/opt/nodejs/bin/npx -> /opt/nodejs/lib/node_modules/npx/index.js
+ npx@10.2.0
added 484 packages from 651 contributors in 34.539s

已安装?当然可以吗?

$ whereis npx
npx: /opt/nodejs/bin/npx

对。我不相信你该目录中有什么?

$ v /opt/nodejs/bin/
total 34468
lrwxrwxrwx 1 kingram kingram       45 Sep 17 17:04 create-react-app -> ../lib/node_modules/create-react-app/index.js
-rwxr-xr-x 1 xxxxxxx xxxxxxx 35291184 Sep  6 13:15 node
lrwxrwxrwx 1 xxxxxxx xxxxxxx       38 Sep  6 13:15 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 xxxxxxx xxxxxxx       32 Sep 17 17:10 npx -> ../lib/node_modules/npx/index.js

这有点不对劲。

$ npx -v
-bash: npx: command not found

回到开头。也许不是那样构建的。

$ npx create-react-app my-app
-bash: npx: command not found

我不信任你是正确的。

所以。有经验的用户有什么想法吗?

其他信息:

NPM版本

$ npm -v
6.4.1

npm在哪里?

$ which npm
/usr/bin/npm

“ ......您应该能够在没有npx前缀的情况下自行执行create-react-app ...”

$ create-react-app my-app    
-bash: create-react-app: command not found

0 个答案:

没有答案
相关问题