简体   繁体   English

create-react-app 错误:找不到模块“react-scripts/scripts/init.js”

[英]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'

Screenshot截屏

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
  • different project paths不同的项目路径

by the way:顺便一提:

  • the problem disappears when I use --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:笔记:

  1. For npx create-react-app projectName to work. npx create-react-app projectName工作。 Your node and npm should be: Node >= 8.10 and npm >= 5.6您的节点和 npm 应该是:节点 >= 8.10 和 npm >= 5.6
  2. And you will have to uninstall old create-react-app from the machine.你必须从机器上卸载旧create-react-app See the doc: https://create-react-app.dev/docs/getting-started请参阅文档: 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.

相关问题 错误:尝试安装 react 应用程序时找不到模块“react-scripts/scripts/init.js” - Error: cannot find module "react-scripts/scripts/init.js' when tryping to install react app 错误:找不到模块“/app/react-web/react-scripts” - Error: Cannot find module '/app/react-web/react-scripts' 反应:“反应脚本启动”找不到模块 webpack - React: "react-scripts start" cannot find module webpack react-scripts 启动错误(找不到模块'../scripts/start') - 我该如何解决这个问题? - react-scripts start error (Cannot find module '../scripts/start') - how can i fix this? 使用 Moment JS 创建 React-App:找不到模块“./locale” - Create-React-App with Moment JS: Cannot find module “./locale” 如何在没有 react-scripts 的情况下运行 React.js 应用程序? - How to run React.js app without react-scripts? Create React App 提供的 react-scripts package 需要依赖 - The react-scripts package provided by Create React App requires a dependency Create React App 提供的 react-scripts 包需要一个依赖: - The react-scripts package provided by Create React App requires a dependency: react-create-app / react-scripts如何找到入口点? - How does react-create-app/react-scripts find the entry point? 将实用程序脚本添加到 create-react-app React / Typescript 应用程序 - Adding utility scripts to a create-react-app React / Typescript app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM