Reactjs:npm启动失败

时间:2017-09-05 08:53:14

标签: reactjs npm

我正在使用react构建一个项目(使用create-react-app创建项目)并且最近在运行时遇到以下错误

  

npm start

错误如下(我使用的是Ubuntu Linux):

> linguana@0.1.0 start /home/george/code/linguana
> react-scripts start

/home/george/code/linguana/node_modules/react-scripts/scripts/start.js:33
const {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:140:18)
    at node.js:1001:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! linguana@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the linguana@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/george/.npm/_logs/2017-09-05T08_01_42_672Z-debug.log

有人能指出我正确的方向吗?

编辑:这是npm生成的日志:

0 info it worked if it ends with ok
1 verbose cli [ '/home/george/.nvm/versions/node/v5.6.0/bin/node',
1 verbose cli   '/home/george/.nvm/versions/node/v5.6.0/bin/npm',
1 verbose cli   'start' ]
2 info using npm@5.3.0
3 info using node@v5.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle linguana@0.1.0~prestart: linguana@0.1.0
6 info lifecycle linguana@0.1.0~start: linguana@0.1.0
7 verbose lifecycle linguana@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle linguana@0.1.0~start: PATH: /home/george/.nvm/versions/node/v5.6.0/lib/node_modules/npm/bin/node-gyp-bin:/home/george/code/linguana/node_modules/.bin:/home/george/.rvm/gems/ruby-2.2.3/bin:/home/george/.rvm/gems/ruby-2.2.3@global/bin:/home/george/.rvm/rubies/ruby-2.2.3/bin:/home/george/.nvm/versions/node/v5.6.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/george/.rvm/bin:/home/george/.rvm/bin
9 verbose lifecycle linguana@0.1.0~start: CWD: /home/george/code/linguana
10 silly lifecycle linguana@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle linguana@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle linguana@0.1.0~start: Failed to exec start script
13 verbose stack Error: linguana@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/george/.nvm/versions/node/v5.6.0/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:100:13)
13 verbose stack     at EventEmitter.emit (events.js:185:7)
13 verbose stack     at ChildProcess.<anonymous> (/home/george/.nvm/versions/node/v5.6.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:100:13)
13 verbose stack     at ChildProcess.emit (events.js:185:7)
13 verbose stack     at maybeClose (internal/child_process.js:827:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid linguana@0.1.0
15 verbose cwd /home/george/code/linguana
16 verbose Linux 4.2.0-42-generic
17 verbose argv "/home/george/.nvm/versions/node/v5.6.0/bin/node" "/home/george/.nvm/versions/node/v5.6.0/bin/npm" "start"
18 verbose node v5.6.0
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error linguana@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the linguana@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 [ 1, true ]

1 个答案:

答案 0 :(得分:3)

解构就像你看到错误的部分被添加到版本6中的node.js. react-scripts似乎依赖于更新的版本,因此更新节点版本可能会解决这个问题。