节点不能与babel一起运行

时间:2018-06-05 07:53:22

标签: node.js ecmascript-6 babeljs babel

我正在按照本教程https://medium.com/@bneiluj/es6-with-babel-in-your-node-app-3f254f6aa65f来理解在babel上运行的节点。因此,在运行npm run prepublish

之后出现了以下错误,所以我做了一切但不能运行babel
> 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

0 个答案:

没有答案