[英]'npx create-react-app [name] --template typescript' error
This ( https://imgur.com/a/m071dgX ) is the error I get.这( https://imgur.com/a/m071dgX )是我得到的错误。 Literally a few minutes ago I was able to create projects with "npx create-react-app [NAME] --template typescript" ... now I get this error.
几分钟前,我能够使用“npx create-react-app [NAME] --template typescript”创建项目......现在我收到了这个错误。 I've tried updating node.js, removing the node_modules folder, and other things but nothing's working.
我试过更新 node.js、删除 node_modules 文件夹和其他东西,但没有任何效果。 I'm a new developer so I try not to ask too many questions but this is really frustrating.
我是一名新开发人员,所以我尽量不问太多问题,但这真的令人沮丧。
So this might not be a true fix, but rather a workaround:所以这可能不是真正的修复,而是一种解决方法:
In your created app folder, open package.json file.在您创建的应用程序文件夹中,打开 package.json 文件。
Change react-scripts
and typescript
versions, to:将
react-scripts
和typescript
版本更改为:
"react-scripts": "3.4.4",
"typescript": "^3.2.1",
Next, remove package.lock.json
, yarn.lock
, node_modules
and tsconfig.json
.接下来,删除
package.lock.json
、 yarn.lock
、 node_modules
和tsconfig.json
。 Run $ npm install
and then $ npm start
should work normally.运行
$ npm install
然后$ npm start
应该可以正常工作。
Note that here we are using an older version of react-scripts
.请注意,这里我们使用的是旧版本的
react-scripts
。
I came across this and for me running the command with yarn
worked but the command with npx
did not.我遇到了这个问题,对我来说,使用
yarn
运行命令有效,但使用npx
的命令没有。 Might be worth trying.可能值得一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.