Heroku cannot find `babel-core / register`

I am creating a small url-shortener application using NodeJS. I write code in ES6 using an index file that Babel imports and then my server:

require('babel-core/register');
require('./server.js');

This works fine on localhost, and all of my ES6 codes work correctly.

However, when I successfully deploy to Heroku, I get an application error message with the following display in heroku logs --tail -a shortenthisurl:

2016-02-06T12:31:14.074071+00:00 heroku[slug-compiler]: Slug compilation started
2016-02-06T12:31:14.074080+00:00 heroku[slug-compiler]: Slug compilation finished
2016-02-06T12:31:13.936954+00:00 heroku[api]: Deploy f576f69 by rory88@gmail.com
2016-02-06T12:31:13.936991+00:00 heroku[api]: Release v17 created by rory88@gmail.com
2016-02-06T12:31:14.230327+00:00 heroku[web.1]: State changed from crashed to starting
2016-02-06T12:31:15.215417+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-02-06T12:31:16.816525+00:00 app[web.1]: module.js:341
2016-02-06T12:31:16.816534+00:00 app[web.1]:     throw err;
2016-02-06T12:31:16.816535+00:00 app[web.1]:     ^
2016-02-06T12:31:16.816536+00:00 app[web.1]:
2016-02-06T12:31:16.816541+00:00 app[web.1]: Error: Cannot find module 'babel-core/register'
2016-02-06T12:31:16.816541+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:339:15)
2016-02-06T12:31:16.816542+00:00 app[web.1]:     at Function.Module._load (module.js:290:25)
2016-02-06T12:31:16.816543+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-02-06T12:31:16.816544+00:00 app[web.1]:     at require (internal/module.js:16:19)
2016-02-06T12:31:16.816544+00:00 app[web.1]:     at Object.<anonymous> (/app/index.js:1:63)
2016-02-06T12:31:16.816545+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-02-06T12:31:16.816546+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-02-06T12:31:16.816546+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-02-06T12:31:16.816547+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-02-06T12:31:16.816547+00:00 app[web.1]:     at Function.Module.runMain (module.js:447:10)
2016-02-06T12:31:17.669897+00:00 heroku[web.1]: State changed from starting to crashed
2016-02-06T12:31:17.655186+00:00 heroku[web.1]: Process exited with status 1
2016-02-06T12:31:40.693975+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shortenthisurl.herokuapp.com request_id=c2bffaba-4de6-4310-b535-4ff37ec637ad fwd="86.1.35.144" dyno= connect= service= status=503 bytes=

Here is mine package.json:

{
  "name": "shortenthisurl",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "mocha --compilers js:babel-register -w",
    "start": "node server.js",
    "babel-node": "babel-node --stage 0 --ignore='foo|bar|baz'",
    "build": "babel -d lib"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel": "^6.3.26",
    "chai": "^3.5.0",
    "express": "^4.13.4",
    "lodash": "^4.2.1",
    "mocha": "^2.4.5",
    "mongoose": "^4.4.1",
    "request": "^2.69.0"
  },
  "devDependencies": {
    "babel-core": "^6.4.5",
    "babel-preset-es2015": "^6.3.13",
    "babel-register": "^6.4.3"
  }
}

Maybe I'm importing Babel incorrectly. Do you have any tips on how I can make this work?

Here is the link to the complete repo on Github: https://github.com/alanbuchanan/shortenthisurl

+4
1

, . Heroku dependencies, .

Heroku:

Npm , NPM_CONFIG. production = true .

, babel-core devDependencies dependencies, , ES6- ES5.

+7

Source: https://habr.com/ru/post/1627565/


All Articles