错误:找不到相对于目录的预设“”

时间:2018-11-03 07:29:43

标签: javascript node.js express babel

我无法将es-15与node.js一起使用,我不认为脚本之前存在问题。

Package.json在下面

{
  "name": "server",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "nodemon index.js --exec babel-node --presets es2015, stage-2"
  },
  "license": "MIT",
  "dependencies": {
    "express": "^4.16.4",
    "express-graphql": "^0.7.1",
    "graphql": "^14.0.2",
    "mongoose": "^5.3.8"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "nodemon": "^1.18.5"
  }
}

在运行npm start时,出现以下错误

> server@1.0.0 start /home/ansh/boo/server
> nodemon index.js --exec babel-node --presets es2015, stage-2

[nodemon] 1.18.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node index.js --presets es2015, stage-2`
/home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^

Error: Couldn't find preset "" relative to directory "/home/ansh/boo/server"
    at /home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/home/ansh/boo/server/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/home/ansh/boo/server/node_modules/babel-register/lib/node.js:103:45)
    at loader (/home/ansh/boo/server/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/home/ansh/boo/server/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:605:32)
[nodemon] app crashed - waiting for file changes before starting...

0 个答案:

没有答案