由于缺少脚本' start'无法启动React App。

发布于 2025-02-02 12:18:22 字数 759 浏览 3 评论 0原文

我是新手反应js. trying以运行一个简单的应用程序并遇到此错误,并且无法弄清楚

D:\React app\react-app1>npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Muralidharan\AppData\Local\npm-cache\_logs\2022-05-29T08_51_37_315Z-debug-0.log

这是

{
  "name": "react-app1",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-scripts": "5.0.1"
  }
}

什么问题。还是过时的版本类似的版本?

I'm newbie to react js.Trying to run a simple app and getting this error and can't figure out what's wrong

D:\React app\react-app1>npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Muralidharan\AppData\Local\npm-cache\_logs\2022-05-29T08_51_37_315Z-debug-0.log

This is package.json file

{
  "name": "react-app1",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-scripts": "5.0.1"
  }
}

Anything wrong with installation? or outdated version something like that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

节枝 2025-02-09 12:18:22

这发生了,因为您没有脚本在package.json文件中称为“ start”。这是包含此类脚本的package.json文件的示例:

{
  "name": "your-project",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "node main.js"
  },
  "author": "Muralidharan",
  "dependencies": {
  }
}

This happens becaue you have no script called "start" in your package.json file. Here is an example of a package.json file with such script:

{
  "name": "your-project",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "node main.js"
  },
  "author": "Muralidharan",
  "dependencies": {
  }
}
撩起发的微风 2025-02-09 12:18:22

将此添加到您的软件包。JSON

 "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
  },

启动是您需要触发react-script运行项目的命令
构建,测试和弹出是您需要的其他命令

add this to your package.json

 "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
  },

start is the command you need that trigger react-script to run your project
build, test and eject are other command you will need for development process

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文