Cannot find module Source-map-support

See original GitHub issue

Hi, I’m trying to push my build on production and I’m getting this error

Cannot find module '/Users/NAME/FOLDER/PROJECT_NAME/node_modules/source-map-support/source-map-support.js'

Anyone know how to fix this?

Thank you very much!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
jalvarado91commented, Oct 8, 2018

I’m having this issue when I try to run this on Docker. I have a build stage that compiles the build/main.js bundle and then removes all dev deps and any files that my app doesn’t need, then I have another step that simply runs npm start. In theory that should be enough but into the same issue.

> node ./build/main.js

module.js:550
    throw err;
    ^

Error: Cannot find module 'source-map-support/register'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
4reactions
jaredpalmercommented, Feb 14, 2017

@thierryskoda When I pushed the change in 0.0.9 I had a feeling this would be an issue. The problem is that lerna doesn’t handle the local npm symlink properly without that require.resolve(), which makes developing backpack really really annoying. We need to figure out a better solution.

As a workaround you should remove webpack.BannerPlugin() using backpack.config.js, add source-map-support as a dependency (npm i source-map-support), and then add import 'source-map-support/register' to the top of your entry file (src/index.js or whatever).

// backpack.config.js
module.exports = {
  webpack: (config, options) => {
    ...
    config.plugins.splice(1, 1) // remove the BannerPlugin
    return config
  }
}
//src/index.js or whatever
import 'source-map-support/register'

Do you think it’s a best practice to build in production? I though it was much better to build locally than just push the build folder in production.

Nowadays our build servers are the same VMs as our production machines so paths always match. However, I know that is not the case for everyone, especially for people using SaaS CI’s and many PaaS providers. When we used to use Heroku with webpack or grunt, we used the postinstall npm script where we ran our build step.

For example:

{
   "scripts": {
     ...
    "build": "backpack build",
    "postinstall": "npm run build"
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest - Cannot find module 'source-map' from ... - Stack Overflow
I've got the problem that I get the error: Cannot find module 'source-map' from 'source-map-support.js' Ran all test suites matching ...
Read more >
[Bug?]: jest fails with Cannot find module 'source-map-support ...
Self-service I'd be willing to implement a fix Describe the bug I'm currently trying to migrate from the PnP linker to pnpm.
Read more >
source-map-support - npm
Start using source-map-support in your project by running `npm i source-map-support`. There are 6717 other projects in the npm registry ...
Read more >
Error: Cannot find module 'source-map' - Appium Discuss
Error: Cannot find module 'source-map' ... \AppData\Roaming\npm\node_modules\appium\node_modules\source-map-support\source-map-support.js ...
Read more >
node_modules/source-map-support · master - Gitlab inria
This module provides source map support for stack traces in node via the V8 ... the V8 engine doesn't and Error.prototype.stack will 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