我剛剛導入我的Reactjs項目到新機器上的Ubuntu和安裝最依賴與npm install
成功吧以下內容:NPM的NodeJS腳本失敗,出現「語法錯誤:意外的標記{」
npm WARN optional Skipping failed optional dependency /react-scripts/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
試圖運行
> [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._compile (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
嘗試運行任何npm
腳本包括npm run build
所有失敗的確切同樣的錯誤引用在每個相同的路線:與npm start
項目失敗SyntaxError中的文件:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (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
在我的原始機器上運行相同的腳本,即Mac,則成功。
我試過重新安裝node
/npm
這不能解決問題。據推測,這是可選的依賴關係導致失敗?
任何幫助表示讚賞。
什麼是/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/start.js:33,第33行? –
線33 - 38:'常量{ choosePort, createCompiler, prepareProxy, prepareUrls, } =需要( '反應-DEV-utils的/ WebpackDevServerUtils');'其中的唯一事情佔用線路33是'常量{'並且每個逗號分隔的項目都在一個新行中。 – Shiri
儘管此引用的行將根據我運行的腳本而改變,但當它碰到大括號時總會失敗。然後使用SyntaxError失敗,並引用上面的堆棧跟蹤,無論腳本失敗,它都是相同的。運行'npm run build'會導致它抱怨:'/root/17-visit-booker-frontend/node_modules/react-scripts/scripts/build.js:60 ({stats,previousFileSizes,warnings})=> { '並指出第一次出現花括號。 – Shiri