简体   繁体   English

无法识别“npm”中的 create-react-app 结果

[英]create-react-app results in "npm" is not recognized

I have been working with react for almost 1 year.我从事 React 工作将近 1 年。 I didn't have this problem but since I re-installed my OS, I cant use commands like: ' npx create-react-app my-app ' and it get this result:我没有遇到这个问题,但是因为我重新安装了我的操作系统,我不能使用像这样的命令:' npx create-react-app my-app ' 并且它得到了这个结果:

'"node"' is not recognized as an internal or external command,
operable program or batch file.

I have我有

  • installed nodejs and added it's path to environment variables.安装了 nodejs 并将其添加到环境变量的路径。
  • restarted VSCode.重新启动 VSCode。
  • restarted the system.重新启动系统。
  • uninstalled everything including files in Roaming directory.卸载了所有内容,包括 Roaming 目录中的文件。
  • changed the installation directory for nodejs and updated it's path更改了 nodejs 的安装目录并更新了它的路径
  • cleared node cache清除节点缓存

but nothing works.但没有任何效果。

When I type in 'node -v' or 'npm -v' i get the version back.当我输入“node -v”或“npm -v”时,我会取回版本。 so they are recognized in the system.所以他们在系统中被识别。 and also when I use yarn, this happens:而且当我使用纱线时,也会发生这种情况:

yarn create react-app client

yarn create v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-react-app@4.0.3" with binaries:
      - create-react-app

Creating a new React app in D:\Projects\DEVCONNECTOR\client.

'npm' is not recognized as an internal or external command,
operable program or batch file.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

'npm' is not recognized as an internal or external command,
operable program or batch file.

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts@0.9.x has failed.

Deleting generated file... package.json
Deleting client/ from D:\Projects\DEVCONNECTOR
Done.
error Command failed.
Exit code: 1
Command: C:\Users\damon\AppData\Local\Yarn\bin\create-react-app
Arguments: client
Directory: D:\Projects\DEVCONNECTOR
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

So it first begins to install the package but then I get the same error and the package gets deleted.所以它首先开始安装 package 但随后出现相同的错误并且 package 被删除。 although I can use yarn in other commands like starting the server etc.尽管我可以在启动服务器等其他命令中使用 yarn。

Thanks in advance提前致谢

Try deleting node modules and package-lock.json and run command yarn create-react-app client .尝试删除节点模块package-lock.json并运行命令yarn create-react-app client

If it does not work try yarn create-react-app client --legacy-peer-deps如果它不起作用尝试yarn create-react-app client --legacy-peer-deps

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

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