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

Closed
2474 opened this Issue Sep 7, 2016 · 24 comments

Projects

None yet

8 participants

@2474
2474 commented Sep 7, 2016 edited

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
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.

@jlengstorf jlengstorf closed this Sep 7, 2016
@2474
2474 commented Sep 7, 2016 edited

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

{
  "presets": ["es2015-rollup"]
}
@jlengstorf
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
@2474
2474 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
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
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.

@2474
2474 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
yonida commented Sep 12, 2016 edited

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
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.

@LisMin
LisMin 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.

@jlengstorf jlengstorf closed this Sep 23, 2016
@xrr2016
xrr2016 commented Sep 30, 2016

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

@gongph
gongph commented Oct 18, 2016

@jlengstorf #12 help me!

@gongph
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
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
gongph commented Oct 18, 2016

my repo is Here . @jlengstorf

@jlengstorf
Owner

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

@jlengstorf jlengstorf reopened this Oct 18, 2016
@jlengstorf jlengstorf closed this Oct 18, 2016
@wellnoidea

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
Owner
jlengstorf commented Oct 18, 2016 edited

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
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

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

@wellnoidea
wellnoidea commented Oct 25, 2016 edited

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
wellnoidea commented Oct 25, 2016 edited

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
wellnoidea commented Oct 25, 2016 edited

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

@jlengstorf
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!

@jlengstorf jlengstorf added a commit to jlengstorf/code.lengstorf.com that closed this issue Oct 28, 2016
@jlengstorf edit(config): note about older npm versions and Babel presets
Also updated the posts to use the new series feature. (Still needs
the series navigation, though, if I want to figure out starting
videos at given times using AMP.)

Closes jlengstorf/learn-rollup#2 (<-- does this work?)
edcdaa7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment