将什么放入json包中以运行create-react-app

问题描述 投票:1回答:0

我正在尝试遵循一些入门反应课程,但是我无法运行npm start来使create-react-app工作。 我在Windows 10上。我通常收到的错误是“ npm ERR!missing script:start”

我应该提到我是从命令行执行的,这是我的Node.js命令提示符

通读一些文档: https : //docs.npmjs.com/creating-a-package-json-file https://www.npmjs.com/package/npm-start-command

搜索的堆栈溢出: 缺少脚本启动等。

跑npm install npm-start-command --save-dev

尝试将npm降级到4.6.1,然后再升级回最新版本

使用npm init创建了多个版本的package.json

我已经包含“开始”:以及package.json脚本部分下的各种想法,包括

"start": "node index.js"
"start": "index.js"
"start": "server.js"
{
  "name": "react",
  "version": "1.0.0",
  "description": "react json ",
  "main": "index.js",
  "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Julie",
  "license": "ISC"
}

问题在于,到目前为止还没有index.js,因为我正在创建用来学习react的模块还没有启动任何代码。 这是我要尝试的Pluralsight和eggheads.io课程中的第一步。 然后,我应该能够转到http:// localhost:3000 /并查看Start React映像。

在Pluralsight上与作家liam-mclennan进行“反应基础”仅从以下这些方向开始:

1. npm install -g create-react-app
2. create-react-app click-counter (this is the name of the app)
3. cd click-counter
4. npm start

我已经尝试将package.json放在create-react-app目录和click-counter(它下面的项目文件夹)中

Eggheads.io“开始学习React”具有以下指示:

1. npm -i create-react-app -g
2. create-react-app react-app
3. cd react-app
4. react-app subl .
5. npm start

我在这里得到一个略有不同的错误:

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'C:\Users\julie\react-app\examples\app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./examples/app.js

然后package.json是自动创建的:

{
  "name": "react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

reactjs npm-scripts npm-start
© www.soinside.com 2019 - 2024. All rights reserved.