我打算用 reactJS + nodeJS + babel(ES6)+ webpack 启动一个Web项目。但我目前在ES6环境设置步骤中被阻止。
无法使用节点
运行某些ES6语句启动应用程序的步骤
$ npm install
$ npm run build
$ set DEBUG=myapp:* & npm start
Errortrace:
SyntaxError: Unexpected token export 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 Module.require (module.js:367:17) at require (internal/module.js:16:19) ... ...
{ "name": "myapp", "version": "0.0.0", "private": true, "scripts": { "build": "webpack", "start": "node ./bin/www" }, "dependencies": { "alt": "^0.18.2", "body-parser": "~1.13.2", "cookie-parser": "~1.3.5", "debug": "~2.2.0", "ejs": "^2.4.1", "express": "~4.13.1", "morgan": "~1.6.1", "react": "^0.14.7", "react-dom": "^0.14.7", "serve-favicon": "~2.3.0", "webpack": "^1.12.14" }, "devDependencies": { "babel-cli": "^6.5.1", "babel-core": "^6.5.2", "babel-loader": "^6.2.4", "babel-polyfill": "^6.3.14", "babel-preset-es2015": "^6.5.0", "babel-preset-react": "^6.5.0", "copy-webpack-plugin": "^0.2.0", "webpack": "^1.12.6", "webpack-dev-server": "^1.12.1" } }
{ "presets": [ "es2015" ] }
click here托管在Github上
答案 0 :(得分:0)
并非所有ES6的功能都在生产中,并且在nodejs中默认启用。模块属于其中之一。您可能需要运行node.js - 和谐标志,或者特别是关于模块: - harmony_modules
查看所有正在进行的列表'功能使用以下命令:
$ node --v8-options | grep 'in progress'