reactjs / express-react-views

This is an Express view engine which renders React components on server. It renders static markup and *does not* support mounting those views on the client.
Other
2.73k stars 260 forks source link

Error: Cannot find module 'babel-core' #139

Open blakewilson opened 5 years ago

blakewilson commented 5 years ago

Hi team,

I'm getting the following error:

Error: Cannot find module 'babel-core'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at requireReact (/Users/blakewilson/projects/projectName/node_modules/consolidate/lib/consolidate.js:1338:51)
    at Object.newLoader [as .jsx] (/Users/blakewilson/projects/projectName/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at View.renderFile [as engine] (/Users/blakewilson/projects/projectName/node_modules/express-react-views/index.js:66:23)
    at View.render (/Users/blakewilson/projects/projectName/node_modules/express/lib/view.js:135:8)
    at tryRender (/Users/blakewilson/projects/projectName/node_modules/express/lib/application.js:640:10)
    at Function.render (/Users/blakewilson/projects/projectName/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/Users/blakewilson/projects/projectName/node_modules/express/lib/response.js:1008:7)
    at Listing.find.populate.select.limit.sort.then.listings (/Users/blakewilson/projects/projectName/server.js:90:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)

When using the following packages:

"dependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.3.0",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "body-parser": "^1.18.3",
    "dotenv": "^6.2.0",
    "email-templates": "^5.0.3",
    "express": "^4.16.4",
    "express-react-views": "^0.11.0",
    "express-validator": "^5.3.1",
    "jsonwebtoken": "^8.4.0",
    "mime": "^2.4.0",
    "moment": "^2.24.0",
    "mongoose": "^5.4.7",
    "nodemailer": "^5.1.1",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-render-html": "^0.6.0",
    "slugify": "^1.3.4",
    "stripe": "^6.23.0",
    "url-parse": "^1.4.4",
    "uuid": "^3.3.2"
  },

Using babel-core, babel-preset-env, babel-preset-react, etc work fine. However, I'd like to run Babel 7, and from viewing the issues, this seems supported. Am I doing something wrong?

Thanks for any help!

blakewilson commented 5 years ago

Alright, after some serious debugging I found that the issue Error: Cannot find module 'babel-core' is somehow related to requiring the package email-templates in Node i.e.

const Email = require('email-templates')

Any thoughts as to why this may be happening would be really helpful! Unfortunately, email-templates isn't really a package I'd be able to give up easily.

zpao commented 4 years ago

Did you get this worked out? Not much I can do about another package needing babel-core :/

blakewilson commented 4 years ago

@zpao Unfortunately, my solution was to uninstall the package 😬I felt the same way once I realized babel-core was coming from another dependency.