Skip to content

'babel-preset-es2015' module not found #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Sep 7, 2016 · 28 comments
Closed

'babel-preset-es2015' module not found #2

ghost opened this issue Sep 7, 2016 · 28 comments

Comments

@ghost
Copy link

ghost commented Sep 7, 2016

Have any idea? Seems like npm install --save-dev babel-preset-es2015-rollup installed just fine however below still happens.

Node: 4.4.5

C-C02P37U0G3QD:learn-rollup evans.863$ ./node_modules/.bin/rollup -c
{ [Error: Cannot find module 'babel-preset-es2015'] code: 'MODULE_NOT_FOUND' }
Error transforming /Users/evans.863/work/zack/learn-rollup/src/scripts/main.js with 'babel' plugin: Cannot find module 'es2015'
Error: Error transforming /Users/evans.863/work/zack/learn-rollup/src/scripts/main.js with 'babel' plugin: Cannot find module 'es2015'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.require.resolve (internal/module.js:16:19)
    at module.exports (/Users/evans.863/work/zack/learn-rollup/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/index.js:76:21)
    at Object.<anonymous> (/Users/evans.863/work/zack/learn-rollup/node_modules/babel-preset-es2015-rollup/index.js:3:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki

EDIT: My .babelrc is:

{
  "presets": ["es2015-rollup"]
}
@jlengstorf
Copy link
Owner

It looks like you've installed the babel-preset-2015-rollup, but you're trying to include babel-preset-es2015.

Double-check that your .babelrc looks like this:

{
  "presets": [ "es2015-rollup" ]
}

That should fix the problem.

@ghost
Copy link
Author

ghost commented Sep 7, 2016

@jlengstorf Thanks for the quick response dude. My .babelrc is in fact:

{
  "presets": ["es2015-rollup"]
}

@jlengstorf
Copy link
Owner

That's odd.

Just in case, try this:

npm prune
npm cache clean
npm install

Then run it again.

For some sanity-checking: .babelrc is in the app root, along with package.json, and that's where you're running the Rollup command, right?

@jlengstorf jlengstorf reopened this Sep 7, 2016
@ghost
Copy link
Author

ghost commented Sep 7, 2016

I just pruned, cleared cache and installed again and called ./node_modules/.bin/rollup -c from root and still getting that error.

I went ahead and created a repo if you are interested in checking it out. I'm sure you are busy so no rush.

Also thanks for the write up on rollup.js I know I find it extremely helpful.

@eylon-uk
Copy link

eylon-uk commented Sep 8, 2016

I also had that issue and found a fix here: https://github.com/rollup/rollup-plugin-babel/issues/72
Talkbacked it on the youtube post too.

Again, thank you J for the great Rollup course. I learn in lots of places, some are well established and funded organizations and your teaching and course configuration is well above the standard. I'd love it if you would produce one about Ramda and functional JS.

@jlengstorf
Copy link
Owner

@2474 This is odd, because I just cloned your repo, cleaned my npm cache, and ran ./node_modules/.bin/rollup -c and... it all worked as expected. Are you on Mac/OS X?

I'm not sure if I've got something locally installed that would change the outcome you're getting, but here's my current setup:

$ node -v
v4.4.5
$ npm -v
3.10.4
$ ./node_modules/.bin/rollup -c
# No error here.

# For the sake of completeness, my globally-installed packages.
$ npm list -g --depth=0
/usr/local/lib
├── bower@1.7.9
├── hexo-cli@1.0.2
├── hugo@0.0.3
├── node-libs-browser@1.0.0
└── npm@3.10.4

But, like @eylon-uk mentioned, rollup/rollup-plugin-babel#72 has a fix. The relevant config is here:

{
  "presets": [
    [
      "es2015",
      {
        "modules": false
      }
    ]
  ],
  "plugins": ["external-helpers"]
}

I just tried that in your repo and it works as expected. Give it a shot and let me know if it's still causing problems.

@ghost
Copy link
Author

ghost commented Sep 8, 2016

I'm:

Node 4.4.5
NPM 2.15.5

OSX Yosemite 10.10.5

I'll try updating NPM and all else, I'll check out the issue @eylon-uk mentioned.

Thanks for looking into this guys!

@yonida
Copy link

yonida commented Sep 12, 2016

I have the same issue.
node v4.2.2
npm 2.14.7
osx yosemite 10.11.6

The above solution did not work.
First I had to install babel-plugin-external-helpers.
Then I got the following error:
'babel' plugin: Couldn't find preset "es2015" relative to directory ..

@jlengstorf
Copy link
Owner

@yonida Just to sanity check: is your .babelrc in the same directory as node_modules?

If you haven't already, also try:

npm install --save-dev babel-preset-es2015

That plus the fix in my comment above should get you up and running.

@itsHcf
Copy link

itsHcf commented Sep 20, 2016

I had the same issue ,
and i modified .babelrc to
{ "presets": [ [ "es2015", { "modules": false } ] ], "plugins": ["external-helpers"] }
and have it fixed.

@xrr2016
Copy link

xrr2016 commented Sep 30, 2016

I try { "presets": [ [ "es2015", { "modules": false } ] ] },it works;

@gongph
Copy link

gongph commented Oct 18, 2016

@jlengstorf #12 help me!

@gongph
Copy link

gongph commented Oct 18, 2016

我看了以上评论,还是没能解决我的问题!当我运行 npm run dev 还是报这个错误:

Error transforming D:\workSpace\git\rollup-learning\src\scripts\main.js with 'babel' plugin: It look
s like your Babel configuration specifies a module transformer. Please disable it. If you're using t
he "es2015" preset, consider using "es2015-rollup" instead.

@jlengstorf
Copy link
Owner

@gongph please share your repo. This looks like a configuration error.

Please use the config in this comment and see if it helps.

@gongph
Copy link

gongph commented Oct 18, 2016

my repo is Here . @jlengstorf

@jlengstorf
Copy link
Owner

@gongph Your .babelrc needs to match the config I've shared with you twice now. Check the previous comments for the correct config.

@wellnoidea
Copy link

Any explanation where this is coming from? Tested the repo without modifications. Works on one machine (OS X) fails on the other as described here (Ubuntu 16.04, although I doubt that the OS is the problem).
It is pretty frustrating having to add a config addition on specifically for one machine without getting the background.

(P.S.: many thanks for the tutorial)

@jlengstorf
Copy link
Owner

jlengstorf commented Oct 18, 2016

I wish I knew. I'm thinking this should probably be opened as an issue on rollup/babel-preset-es2015-rollup, because it's intermittent and — at least judging by the errors — shouldn't be happening.

@wellnoidea, would you mind sharing the error code you're getting on the machine that fails? That'll probably be really helpful for the preset's maintainers. Once I have that, I'll open an issue.

@jlengstorf jlengstorf reopened this Oct 18, 2016
@jlengstorf
Copy link
Owner

@wellnoidea I edited my last comment to mention you, but I'm not sure if it actually notified you. (If so, sorry!)

If it didn't, I'm hoping to get the error code you're getting on the machine that fails. I'd like to open an issue with the babel-preset-es2015-rollup repo to dig into this, but I don't have the the information they'll need to debug it.

@wellnoidea
Copy link

@jlengstorf Sorry for the delay. I'll post code & error by tomorrow.

@wellnoidea
Copy link

wellnoidea commented Oct 25, 2016

Checked both machines
first runs npm@3.6.0, everything works fine
the second one runs npm@2.15.9, install fails with

{ [Error: Cannot find module 'babel-preset-es2015'] code: 'MODULE_NOT_FOUND' }
Error transforming /[...]/rollup-babel/script.js with 'babel' plugin: Cannot find module 'es2015' (While processing preset: "/[...]/rollup-babel/node_modules/babel-preset-es2015-rollup/index.js")

after upgrading npm on the second machine to 3.6.0 installation works just fine

@wellnoidea
Copy link

wellnoidea commented Oct 25, 2016

Confirmed. Downgrading to npm 2.15.9, reinstalling the node dependencies via npm will bring the error back.
Going up to 3.6.0 again and reinstalling and everything runs just fine.

@wellnoidea
Copy link

wellnoidea commented Oct 25, 2016

I tested with this repo and a minimized version:
https://github.com/wellnoidea/babel-rollup

@jlengstorf
Copy link
Owner

Awesome: it's an npm version issue and not a ghost. :)

That's incredibly helpful. I'll add a note to the article and close this afterward. Very much appreciate your help, @wellnoidea!

@lazercaveman
Copy link

lazercaveman commented Sep 5, 2018

The solution is to use a newer version:

npm install --save-dev gulp-babel@7 babel-core babel-preset-env

@shoaibhaseeb
Copy link

Having the same issue, I tried all the solution proposed above having no success.
issue

@Jatin-8898
Copy link

Having the same issue....

ERROR in ./js/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'babel-preset-es2015' from 'C:\xampp\htdocs\REACT_PROJECTS\RGR'
at Function.module.exports [as sync] (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules\resolve\lib\sync.js:58:15)
at resolveStandardizedName (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\files\plugins.js:101:31)
at resolvePreset (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\files\plugins.js:58:10)
at loadPreset (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\files\plugins.js:77:20)
at createDescriptor (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\config-descriptors.js:154:9)
at items.map (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\config-descriptors.js:109:50)
at Array.map ()
at createDescriptors (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\config-descriptors.js:109:29)
at createPresetDescriptors (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\config-descriptors.js:101:10)
at passPerPreset (C:\xampp\htdocs\REACT_PROJECTS\RGR\node_modules@babel\core\lib\config\config-descriptors.js:58:96)
@ multi ./node_modules/webpack-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./js/app.js main[2]
i 「wdm」: Failed to compile.

@karthik2883
Copy link

karthik2883 commented Dec 3, 2019

simply change our .babelrc file. Here is the example of new .babelrc file :
npm install --save-dev @babel/preset-env
{
"presets": [
"@babel/preset-env"
]
}
this will do the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests