[英]create-react-app Error: Cannot find module 'react-scripts/scripts/init.js'
Everytime I try to create a brand new project with create-react-app I get this error:每次我尝试使用 create-react-app 创建一个全新的项目时,我都会收到此错误:
Error: Cannot find module 'react-scripts/scripts/init.js'
THE WAY I CREATE PROJECT:我创建项目的方式:
npx create-react-app new-project
node -v v12.13.1
npm -v 6.12.1
OS Win10
already tried:已经尝试过:
npm uninstall -g create-react-app
by the way:顺便一提:
--use-npm
flag--use-npm
标志时问题消失了Any ideas what the reason can be?任何想法可能是什么原因?
Open your command prompt and type "node -v" as well as "npm -v", What do you get there as a response?打开命令提示符并输入“node -v”和“npm -v”,你会得到什么作为响应?
React-scripts
issue is issue with webpack and babel mostly. React-scripts
问题主要是 webpack 和 babel 的问题。 You should create a brand new project using npx create-react-app projectName
and this is the recommended approach.您应该使用
npx create-react-app projectName
创建一个全新的项目,这是推荐的方法。 This way you don't have to globally install create-react-app
in your machine which was previous approach.这样你就不必在你的机器上全局安装
create-react-app
了,这是以前的方法。
Have a look at the documentation.看看文档。 https://reactjs.org/docs/create-a-new-react-app.html
https://reactjs.org/docs/create-a-new-react-app.html
NOTE:笔记:
npx create-react-app projectName
to work. npx create-react-app projectName
工作。 Your node and npm should be: Node >= 8.10 and npm >= 5.6create-react-app
from the machine.create-react-app
。 See the doc: https://create-react-app.dev/docs/getting-started Here i found an answer to the same issue, https://stackoverflow.com/a/63334241/7857368在这里我找到了相同问题的答案https://stackoverflow.com/a/63334241/7857368
have your tried creating the app with npx create-react-app myapp
you don't need to install the create-react-app globally anymore with this command.您是否尝试使用
npx create-react-app myapp
,您不再需要使用此命令全局安装 create-react-app 。
Try running the following commands:尝试运行以下命令:
npm install
npm install react-scripts
npx create-react-app App-name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.