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

Source map support not working #738

Closed
dave opened this Issue Jan 6, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@dave

dave commented Jan 6, 2018

I followed the instructions to get source maps working, but it's not playing ball. I know nothing about node, so it's possible I'm doing something dumb...

$ npm install --global source-map-support
/usr/local/lib
`-- source-map-support@0.5.0 
  `-- source-map@0.6.1 

$ npm -g ls --depth=0
/usr/local/lib
`-- source-map-support@0.5.0

$ node --require "source-map-support/register" --eval ""
module.js:328
    throw err;
    ^

Error: Cannot find module 'source-map-support/register'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at module.js:498:12
    at Array.forEach (native)
    at Function.Module._preloadModules (module.js:497:12)
    at Function.startup.preloadModules (node.js:859:38)
    at startup (node.js:88:17)
    at node.js:966:3

$ gopherjs test -v fmt
gopherjs: Source maps disabled. Install source-map-support module for nice stack traces. See https://github.com/gopherjs/gopherjs#gopherjs-run-gopherjs-test.
[...]
@dmitshur

This comment has been minimized.

Show comment
Hide comment
@dmitshur

dmitshur Jan 9, 2018

Member

For me, node --require "source-map-support/register" --eval "" produces no output and 0 exit code.

You might need to set NODE_PATH environment variable, so that node knows where to find packages that were installed globally. Is your NODE_PATH already set or not?

What does npm root --global print for you?

For me:

$ npm root --global
/usr/local/lib/node_modules

And so I've added this to my .bash_profile (or equivalent):


# Needed for node... Might need to verify if there's a better way, but it lets source-map-support module get installed globally.
#export NODE_PATH="$(npm root --global)"
export NODE_PATH="/usr/local/lib/node_modules"

(The second line is an optimization, because npm root --global takes non-trivial time to run.)

Let me know if setting NODE_PATH fixes your issue.

Member

dmitshur commented Jan 9, 2018

For me, node --require "source-map-support/register" --eval "" produces no output and 0 exit code.

You might need to set NODE_PATH environment variable, so that node knows where to find packages that were installed globally. Is your NODE_PATH already set or not?

What does npm root --global print for you?

For me:

$ npm root --global
/usr/local/lib/node_modules

And so I've added this to my .bash_profile (or equivalent):


# Needed for node... Might need to verify if there's a better way, but it lets source-map-support module get installed globally.
#export NODE_PATH="$(npm root --global)"
export NODE_PATH="/usr/local/lib/node_modules"

(The second line is an optimization, because npm root --global takes non-trivial time to run.)

Let me know if setting NODE_PATH fixes your issue.

@dmitshur dmitshur added the question label Jan 9, 2018

@dave

This comment has been minimized.

Show comment
Hide comment
@dave

dave Jan 11, 2018

Yup - that did the trick. Thanks!

dave commented Jan 11, 2018

Yup - that did the trick. Thanks!

@dave dave closed this Jan 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment