npx create-react-app 使用旧版本运行

Pyt*_*ony 3 npm reactjs create-react-app npx

最新版本create-react-app4.0.3,但当我运行时npx create-react-app my-app它使用版本 1.5.2 并且也不使用模板运行。我没有任何全局安装,并尝试使用 卸载它npm uninstall -g create-react-app

我的npm版本是7.21.1,node版本是16.9.1

我怎样才能让它发挥作用?请帮忙。

编辑:创建应用程序时有 58 个漏洞,这出现在最后 -

A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.
You can fix this by running npm uninstall -g create-react-app or yarn global remove create-react-app before using create-react-app again.
Run Code Online (Sandbox Code Playgroud)

该文件夹也没有src文件夹,只有node_modules文件夹和package.json文件。

跑步时npm audit fix我得到这个 -

tar  <=4.4.17
Severity: high
Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization - https://github.com/advisories/GHSA-5955-9wpr-37jh
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links - https://github.com/advisories/GHSA-9r2w-394v-53qc
Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization - https://github.com/advisories/GHSA-3jfq-g458-7qm9
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning - https://github.com/advisories/GHSA-r628-mhmh-qjhw
fix available via `npm audit fix`
node_modules/tar
  tar-pack  *
  Depends on vulnerable versions of tar
  node_modules/tar-pack
    create-react-app  >=1.3.0-alpha.58689133
    Depends on vulnerable versions of tar-pack
    node_modules/create-react-app

3 high severity vulnerabilities
Run Code Online (Sandbox Code Playgroud)

Dav*_*vid 6

简洁版本:

npx clear-npx-cache
Run Code Online (Sandbox Code Playgroud)

临时解决方案:

npx create-react-app@latest my-app
Run Code Online (Sandbox Code Playgroud)

现在进行解释。我认为 npx 正在您的计算机上运行旧版本的 create-react-app 。第一次执行此操作时npx create-react-app,该软件包会安装在缓存中。如果包已缓存,npx 不会检查较新的版本。您可以通过添加 @latest 来回避此问题。这会强制 npx 获取包,即使它已被缓存。

更好的解决方案是清除缓存。还有其他有关如何在 Windows 和 Macos 上查找和删除缓存文件夹的指南。该包clear-npx-cache就是这样做的。