简体   繁体   English

sudo:纱线:找不到命令,create-react-app:找不到命令

[英]sudo: yarn: command not found , create-react-app: command not found

I was trying to install react .我试图安装 react 。 I found there are two ways of doing it either through npm or through yarn .我发现有两种方法可以通过 npm 或 yarn 来实现。 I am using Ubuntu 18.04 .我正在使用 Ubuntu 18.04 。 I have installed node and npm .我已经安装了 node 和 npm 。

name@admin-desktop:~$ node -v
v16.14.0
name@admin-desktop:~$ npm -v
8.3.1

After that I have installed yarn via npm through following commands :之后,我通过以下命令通过 npm 安装了纱线:

npm install --global yarn
name@admin-desktop:~$ yarn --version
1.22.19

after that I gave following command :之后我给出了以下命令:

yarn global add create-react-app@1.5.2

it gave following output:它给出了以下输出:

yarn global v1.22.19
[1/4] Resolving packages...
warning create-react-app > tar-pack > tar@2.2.2: This 
version of tar is no longer supported, and will not 
receive security updates. Please upgrade asap.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-react-app@1.5.2" with binaries:
      - create-react-app
Done in 3.53s.

then I gave following command :然后我给出了以下命令:

name@admin-desktop:~$ create-react-app --help
create-react-app: command not found

May I know why this is creating a problem when it successfully installed ?我可以知道为什么在成功安装后会产生问题吗?

I also tried to install react through npm but it again created problem so I tried to seek help from this post when sudo npm install -g was not working so I gave command which npm and it resulted in /home/name/.nvm/versions/node/v16.14.0/bin/npm我也尝试通过 npm 安装 react,但它再次产生了问题,所以当 sudo npm install -g 不起作用时,我试图从这篇文章中寻求帮助,所以我给出了命令which npm并导致/home/name/.nvm/versions/node/v16.14.0/bin/npm

after that I gave command :之后我给出了命令:

sudo ln -s /home/name/.nvm/versions/node/v16.14.0/bin/npm 
/usr/bin/npm

After that I again tried to install react but again got error :之后我再次尝试安装 react 但再次出现错误:

sudo npm install -g create-react-app@1.5.2
/usr/bin/env: ‘node’: No such file or directory

How to resolve these issues?如何解决这些问题?

just do the following steps and the problem is solved:只需执行以下步骤即可解决问题:

npm uninstall -g create-react-app

npx create-react-app@latest my-app-name

you don't need to install create-react-app globaly anymore您不再需要全局安装 create-react-app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM