Skip to content
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

Can't get node-source-map-support to work on node #97

Closed
0xR opened this issue Aug 31, 2015 · 6 comments
Closed

Can't get node-source-map-support to work on node #97

0xR opened this issue Aug 31, 2015 · 6 comments

Comments

@0xR
Copy link

0xR commented Aug 31, 2015

Me (and a colleague) have tried the basic demo from the readme in both node 0.12.7 and 0.10.38, but it doesn't show me the mapped stacktrace. The same occured when I integrated node-source-map-support in my project.

My stacktrace looks like this:

/tmp/smtest/compiled.js:3
throw new Error('test'); // This is the compiled code
      ^
Error: test
    at Object.<anonymous> (/tmp/smtest/compiled.js:3:7)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Is this project broken or am I doing something wrong?

@julien-f
Copy link
Collaborator

This project is not broken, I use it regularly!

But indeed, the demo is not working as it should…

@0xR
Copy link
Author

0xR commented Aug 31, 2015

Ok if the example is wrong I have created a new example that does work:

original.js:

require('source-map-support').install();

throw new Error('test'); // This is the original code

compiled.js:

throw require("source-map-support").install(),new Error("test");
//# sourceMappingURL=compiles.js.map

compiled.js.map:

{"version":3,"sources":["original.js"],"names":["require","install","Error"],"mappings":"AAEA,KAFAA,SAAQ,sBAAsBC,UAExB,GAAIC,OAAM"}

@0xR
Copy link
Author

0xR commented Aug 31, 2015

Maybe put this in a example dir in the repo? to make it easier for people?

@CrabDude
Copy link

CrabDude commented Jan 6, 2016

Ditto. It looks like the culprit for me is the "transform-strict-mode" plugin:

$ cat foo.js 
require('source-map-support').install();

throw new Error('test'); // This is the original code
$ babel-node foo.js 
Error: test
    at Object.<anonymous> (/private/tmp/foo/foo.js:5:7)
    at Module._compile (module.js:399:26)
    at loader (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:130:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:345:32)
    at Function.Module._load (module.js:302:12)
    at Function.Module.runMain (module.js:431:10)
    at /Users/crabdude/.npmprefix/lib/node_modules/babel-cli/lib/_babel-node.js:161:27
    at Object.<anonymous> (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/lib/_babel-node.js:162:7)
    at Module._compile (module.js:399:26)
$ babel-node -V
6.3.17
$ npm ls source-map-support
foo@1.0.0 /private/tmp/foo
└── source-map-support@0.4.0  extraneous

$ node -v
v5.2.0
$ cat .babelrc 
{
  "plugins": ["transform-strict-mode"]
}

It would be nice to know if this is a bug with babel-plugin-transform-strict-mode or node-source-map-support.

Phabricator issue

@seanpoulter
Copy link
Contributor

Re: @CrabDude's "transform-strict-mode" plugin issue:

This isn't a problem for me from babel-node 6.24.0 and node 6.10.

$ npm i babel-cli babel-plugin-transform-strict-mode source-map-support

$ cat foo.js
require('source-map-support').install();
throw new Error('test'); // This is the original code

$ cat .babelrc
{
  "plugins": ["transform-strict-mode"]
}

$ babel-node foo.js
throw new Error('test'); // This is the original code
      ^
Error: test
    at Object.<anonymous> (F:/tmp/@CrabDude/foo.js:2:7)
    at Module._compile (module.js:570:32)
    at loader (F:\tmp\@CrabDude\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (F:\tmp\@CrabDude\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.Module.runMain (module.js:604:10)
    at Object.<anonymous> (F:\tmp\@CrabDude\node_modules\babel-cli\lib\_babel-node.js:154:22)
    at Module._compile (module.js:570:32)

$ babel foo.js --out-file compiled-foo.js --source-maps

$ node compiled-foo.js
throw new Error('test'); // This is the original code
      ^
Error: test
    at Object.<anonymous> (F:\tmp\@CrabDude\foo.js:2:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

@LinusU
Copy link
Collaborator

LinusU commented Apr 29, 2017

This is fixed now 👏

@LinusU LinusU closed this as completed Apr 29, 2017
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

5 participants