question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken with babel-register source mapping

See original GitHub issue

I’m trying to run something like so:

require('babel-register')
// Do stuff

It only works with --no-source-maps. I’m getting this error:

/home/dev/W/app/index.js
/home/dev/W/app/node_modules/babel-register/lib/node.js
/home/dev/W/app/node_modules/babel-core/index.js
/home/dev/W/app/node_modules/babel-core/lib/api/node.js
/home/dev/W/app/node_modules/babel-core/lib/transformation/file/index.js
/home/dev/W/app/node_modules/convert-source-map/index.js
An error occurred while trying to read the map file at node_modules/convert-source-map/foo.js.map
Error: ENOENT: no such file or directory, open 'node_modules/convert-source-map/foo.js.map'

Using this babelrc:

{
    "presets": ["es2015-node5"],
    "plugins": [
        "transform-object-rest-spread",
        "transform-class-properties",
        "add-module-exports",
        [
            "transform-async-to-module-method",
            { "module": "bluebird", "method": "coroutine" }
        ]
    ]
}

Using node v5.12

├─┬ babel-preset-es2015@6.9.0
│ └─┬ babel-plugin-transform-regenerator@6.9.0
│   └─┬ babel-core@6.10.4
│     └── babel-register@6.9.0 
└── babel-register@6.8.0 

Any ideas?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

10reactions
aleclarsoncommented, Jul 7, 2016

This is an issue with thlorenz/convert-source-map.

What’s happening is that both devtool and babel-core depend on convert-source-map. This causes the source map converter to parse itself. This shouldn’t be a problem, except there is a comment in convert-source-map/index.js that has a fake sourceMappingURL.

Just remove this line to fix it. 👍

There are 3 ways to go about this:

  • Remove the comment in both babel-core/node_modules/convert-source-map and devtool/node_modules/convert-source-map. NOTE: This will be overwritten if you reinstall either package.
  • Fork convert-source-map, remove the comment, fork babel-core and devtool and make them depend on your fork of convert-source-map. 😢
  • Wait for @thlorenz to remove the comment in the original repo (or at least in the NPM package that is downloaded by babel-core and devtool).
0reactions
MiracleBluecommented, Oct 9, 2016

Aw damn it 😦 just found this tool and this caught me right off the bat. I need sourcemaps to be there, can’t really do without them. Hopefully the source map folks get time to make a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome source maps not working with Babel - Stack Overflow
Chrome says "Source Map detected" but no dice. I'm using Babel6, Node 6.5 and new --inspect with Chrome DevTools. I think I've spent...
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
Bad source maps caused by multiple transformations ... If you're using two or more JavaScript compilers invoked separately (e.g., Babel + UglifyJS) ...
Read more >
babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. ... you might be transforming the node_modules folder or other unwanted source.
Read more >
Nodemon + Babel + VSCode - Michele Titolo
sourceMaps - VSCode needs to know about source maps. If this setting, or the one in package.json , is missing then you'll get...
Read more >
Babel Roadmap
We would like to release Babel as a pure ESM package. We are now in the process of converting our sources to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found