繁体   English   中英

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

[英]npx create-react-app running with old version

最新版本的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.

该文件夹也没有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

简洁版本:

npx clear-npx-cache

临时解决方案:

npx create-react-app@latest my-app

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

更好的解决方案是清除缓存。 还有其他关于如何在 windows 和 macos 上查找和删除缓存文件夹的指南。 clear-npx-cache执行此操作。

暂无
暂无

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

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