我正在尝试遵循一些入门性的反应性课程,但是我无法运行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
搜索到堆栈溢出: Missing Script Start等
运行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图像。
作者Liam-mclennan在Pluralsight上的反应基础仅提供以下指导:
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目录和点击计数器(位于其下方的项目文件夹中)
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! react-app@1.0.0 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"
]
}
}