我正在按照本教程https://medium.com/@bneiluj/es6-with-babel-in-your-node-app-3f254f6aa65f来理解在babel上运行的节点。因此,在运行npm run prepublish
> cabinet@1.0.0 prepublish
/Users/.../PhpstormProjects/***/cabinet
> npm run compile
> cabinet@1.0.0 compile /Users/.../PhpstormProjects/***/cabinet
> babel — presets es2015 -d lib/ app/
— doesn't exist. presets doesn't exist. es2015 doesn't exist
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! cabinet@1.0.0 compile: `babel — presets es2015 -d lib/ app/`
npm ERR! Exit status 2
但安装了es2015,它在package.json
中清楚地看到了{
"name": "cabinet",
"version": "1.0.0",
"description": "",
"main": "lib/run.js",
"scripts": {
"compile": "babel — presets es2015 -d lib/ app/",
"prepublish": "npm run compile",
"babel-version": "babel --version"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1"
}
}
我的项目结构如下所示
- cabinet/
- app/
- run.js
- lib/ # compiled one from app/
- node_modules/
.babelrc
.package.json