Babel 转码 es6项目问题失败?
全局执行是没有问题
babel ./ -d babel
但是放到script
里面就不行了
package.json
//...
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.14.0",
"babel-core": "^6.18.2",
"babel-eslint": "^6.1.0",
"babel-loader": "^6.2.7",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-preset-stage-2": "^6.18.0",
"babel-preset-stage-3": "^6.17.0",
},
"scripts": {
//...
"build": "babel ./ -d ./babel"
//...
},
//...
.babelrc
{
"presets": [
"es2015",
"react",
"stage-2"
]
}
错误提示
app\redux - fetch\store\configureStore.jsx -> babel\app\redux - fetch\store\configureStore.js
app\routes\index-koa.js -> babel\app\routes\index-koa.js
Error: app/routes/index-koa2.js: You gave us a visitor for the node type "ForAwaitStatement" but it's not a valid type
at verify (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\visitors.js:196:13)
at Object.explode (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\visitors.js:72:3)
at traverse (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\index.js:81:12)
at NodePath.traverse (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\path\index.js:144:25)
at exports.default (D:\luoo\nodejs\node_modules\babel-helper-remap-async-to-generator\lib\index.js:10:8)
at PluginPass.Function (D:\luoo\nodejs\node_modules\babel-plugin-transform-async-to-generator\lib\index.js:13:56)
at newFn (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\visitors.js:276:21)
at NodePath._call (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\path\context.js:76:18)
at NodePath.call (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\path\context.js:48:17)
at NodePath.visit (D:\luoo\nodejs\node_modules\babel-cli\node_modules\babel-traverse\lib\path\context.js:105:12)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! nodejs@1.0.0 build: `babel ./ -d ./babel`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs@1.0.0 build script 'babel ./ -d ./babel'.
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 nodejs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel ./ -d ./babel
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs nodejs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls nodejs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\luoo\nodejs\npm-debug.log
非常感谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试加一个 compact: false
貌似windows下的路径问题,用标准的
babel src -d lib
试试。问题解决了,虽然来回答的人都没能帮我解决,但还是非常感谢能抽空过来回答!
是这样的,我google了一下把
babel-cli babel-core
都重新装了一遍,然后把bable
删除了问题就暂时解决了(有点知其然不知其所以然的感觉,谁知道原理希望不吝赐教)过程中发现两个问题
package.json'生成'的文件不能被正常require(),可以使用babel-plugin-add-module-exports来解决
使用
koa + node.js
搭建的服务器解析后会出现这个下面错误原因因为阮老师原话:
.babelrc
package.json
babel5和babel6不一样 可以参考http://www.ruanyifeng.com/blo...