全局执行是没有问题
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
非常感谢!