admin管理员组文章数量:1243250
I've just imported my Reactjs project to a new machine on Ubuntu and installed most dependencies with npm install
successfully bar the following:
npm WARN optional Skipping failed optional dependency /react-scripts/fsevents:
npm WARN notsup Not patible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not patible with your operating system or architecture: [email protected]
Trying to run the project with npm start
fails with:
> [email protected] start /root/17-visit-booker-frontend
> react-scripts start
/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/start.js:33
const {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'react-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the booking-frontend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs booking-frontend
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls booking-frontend
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/17-visit-booker-frontend/npm-debug.log
Attempting to run any npm
script including npm run build
all fails with the exact same error referencing the same lines in each file in the SyntaxError:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Running the same scripts on my original machine, a Mac, succeed.
I've tried re-installing node
/npm
which do not fix the issue. Is the supposedly optional dependency causing this to fail?
Any help is appreciated.
I've just imported my Reactjs project to a new machine on Ubuntu and installed most dependencies with npm install
successfully bar the following:
npm WARN optional Skipping failed optional dependency /react-scripts/fsevents:
npm WARN notsup Not patible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not patible with your operating system or architecture: [email protected]
Trying to run the project with npm start
fails with:
> [email protected] start /root/17-visit-booker-frontend
> react-scripts start
/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/start.js:33
const {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'react-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the booking-frontend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs booking-frontend
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls booking-frontend
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/17-visit-booker-frontend/npm-debug.log
Attempting to run any npm
script including npm run build
all fails with the exact same error referencing the same lines in each file in the SyntaxError:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Running the same scripts on my original machine, a Mac, succeed.
I've tried re-installing node
/npm
which do not fix the issue. Is the supposedly optional dependency causing this to fail?
Any help is appreciated.
Share Improve this question edited Jul 14, 2017 at 17:03 Shiri asked Jul 14, 2017 at 16:59 ShiriShiri 2,1027 gold badges30 silver badges50 bronze badges 3- And what is at /root/17-visit-booker-frontend/node_modules/react-scripts/scripts/start.js:33, line 33? – James Hatton Commented Jul 14, 2017 at 17:03
-
Lines 33 - 38:
const { choosePort, createCompiler, prepareProxy, prepareUrls, } = require('react-dev-utils/WebpackDevServerUtils');
where the only thing occupying line 33 isconst {
and each ma-separated item is on a new line. – Shiri Commented Jul 14, 2017 at 17:05 -
Although this referenced line will change depending on what script I run but will always fail when it hits a curly brace. It then fails with a SyntaxError and quotes the above stack trace which is identical no matter what script it fails on. Running
npm run build
causes it to plain with :/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/build.js:60 ({ stats, previousFileSizes, warnings }) => {
and points at the first occurrence of a curly brace. – Shiri Commented Jul 14, 2017 at 17:08
1 Answer
Reset to default 10You're using node.js v4 which does not by default support destructuring syntax (the const {field1, field2, ....} = object
) that it is failing on.
You have two options:
- Install a newer version of Node.js
- Run node with the harmony flags that will enable this feature in version 4.x.
本文标签: javascriptNodejs npm scripts fail with quotSyntaxError Unexpected token quotStack Overflow
版权声明:本文标题:javascript - Nodejs npm scripts fail with "SyntaxError: Unexpected token {" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740119353a2227689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论