【发布时间】:2021-03-04 06:30:01
【问题描述】:
我目前正在尝试使用 netlify 部署我的应用程序,但问题是我将我的应用程序克隆到我的新计算机中,现在我遇到了一些问题。
> todolistv2@1.0.0 start /Users/hvaandres/Documents/GitHub/TodoList_React
> npm run build
npm ERR! missing script: build
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hvaandres/.npm/_logs/2021-03-04T06_19_54_506Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolistv2@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todolistv2@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hvaandres/.npm/_logs/2021-03-04T06_19_54_546Z-debug.log
我运行了以下命令 npm install ,但仍然遇到同样的问题。这是我的调试日志:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm@6.14.11
3 info using node@v14.15.5
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle todolistv2@1.0.0~predeploy: todolistv2@1.0.0
6 info lifecycle todolistv2@1.0.0~deploy: todolistv2@1.0.0
7 verbose lifecycle todolistv2@1.0.0~deploy: unsafe-perm in lifecycle true
8 verbose lifecycle todolistv2@1.0.0~deploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/hvaandres/Documents/GitHub/TodoList_React/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
9 verbose lifecycle todolistv2@1.0.0~deploy: CWD: /Users/hvaandres/Documents/GitHub/TodoList_React
10 silly lifecycle todolistv2@1.0.0~deploy: Args: [ '-c', 'npm run build && gh-pages -d build' ]
11 silly lifecycle todolistv2@1.0.0~deploy: Returned: code: 1 signal: null
12 info lifecycle todolistv2@1.0.0~deploy: Failed to exec deploy script
13 verbose stack Error: todolistv2@1.0.0 deploy: `npm run build && gh-pages -d build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid todolistv2@1.0.0
15 verbose cwd /Users/hvaandres/Documents/GitHub/TodoList_React
16 verbose Darwin 19.6.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
18 verbose node v14.15.5
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error todolistv2@1.0.0 deploy: `npm run build && gh-pages -d build`
22 error Exit status 1
23 error Failed at the todolistv2@1.0.0 deploy script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我的 package.json:
{
"name": "todolistv2",
"version": "1.0.0",
"description": "Todo-List",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run build"
},
"keywords": [
"react",
"todolist_project"
],
"author": "Alan A. Haro",
"license": "ISC",
"dependencies": {
"react-icons": "^3.11.0"
}
}
如果有人可以帮助我,我将不胜感激。我只是想了解更多。
【问题讨论】:
-
错误是
npm ERR! missing script: build... 说你的 package.json 文件没有build脚本?您的意思是改为运行npm start吗?您是否首先将cd放入项目目录并安装依赖项?您能否包含有问题的包 JSON 文件? -
我 CD 进入我的项目,我运行 npm start 并给我同样的问题。我删除了 package-lock,json 并运行 npm install。在那之后,我又运行了一次 npm start ,我遇到了同样的问题。
-
同样的问题,您缺少启动命令吗?我们可以看到你的 package.json 文件吗?如果它丢失了,它可能只是简单的 CRA 启动命令,即
"start": "react-scripts start"。 -
准备好了,应该可以看到我的package.json了
-
对,
npm run build将不起作用,因为您也没有build脚本,下面的答案引导您错误。试试我上面评论的启动脚本。我很好奇,你是从哪里克隆这个 repo 的?
标签: javascript node.js reactjs testing npm