作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道这个问题以前曾多次发生在很多人身上,但我昨天花了几个小时试图完成这项工作,但我一生都无法弄清楚。
我正在尝试学习 React,当我尝试使用“npm start”命令时,它是这样的:
$ npm start
> react-app@0.1.0 start /react-app
> /react-app/node_modules/react-scripts/scripts/start.js
sh: 1: /react-app/node_modules/react-scripts/scripts/start.js: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! react-app@0.1.0 start: `/react-app/node_modules/react-scripts/scripts/start.js`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the react-app@0.1.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! /home/sven/.npm/_logs/2020-12-13T06_45_28_430Z-debug.log
我尝试过的事情:
npm start
它没有问题。如果有的话,谁能解释一下
npm start
在这种情况下呢?我现在真的不知道该怎么办。
{
"name": "react-app",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "/home/sven/react-app/node_modules/react-scripts/scripts/start.js"
},
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1"
}
}
这是日志文件:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.14.4
3 info using node@v10.19.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle react-app@0.1.0~prestart: react-app@0.1.0
6 info lifecycle react-app@0.1.0~start: react-app@0.1.0
7 verbose lifecycle react-app@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle react-app@0.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/react-app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle react-app@0.1.0~start: CWD: /react-app
10 silly lifecycle react-app@0.1.0~start: Args: [ '-c',
10 silly lifecycle '/react-app/node_modules/react-scripts/scripts/start.js' ]
11 silly lifecycle react-app@0.1.0~start: Returned: code: 126 signal: null
12 info lifecycle react-app@0.1.0~start: Failed to exec start script
13 verbose stack Error: react-app@0.1.0 start: `/react-app/node_modules/react-scripts/scripts/start.js`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid react-app@0.1.0
15 verbose cwd /react-app
16 verbose Linux 5.4.0-58-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v10.19.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 126
22 error react-app@0.1.0 start: `/react-app/node_modules/react-scripts/scripts/start.js`
22 error Exit status 126
23 error Failed at the react-app@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
最佳答案
我也有这个问题。这是因为 REACT PROJECT 根文件夹的权限问题。当“npm start”或“npm run build”时。 react 应用程序将被构建,它需要在 react 项目目录中创建名为“build”的目录。请尝试
sudo chmod 777 {/path/dir_name}
它对我有用。
关于javascript - 如何让 npm start 在 Ubuntu 上工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65277535/
我是一名优秀的程序员,十分优秀!