Git Product home page Git Product logo

Comments (14)

jalvarado91 avatar jalvarado91 commented on May 23, 2024 12

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)

from backpack.

jaredpalmer avatar jaredpalmer commented on May 23, 2024 4

@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"
  }
}

from backpack.

MirKml avatar MirKml commented on May 23, 2024 1

still is the problem with docker builds as @jalvarado91 said

from backpack.

jaredpalmer avatar jaredpalmer commented on May 23, 2024

Are you building somewhere differently than running in prod?

from backpack.

thierryskoda avatar thierryskoda commented on May 23, 2024

I'm using heroku so I'm doing backpack build and then pushing the build folder (with .Procfile and package.json) to my heroku app.

from backpack.

 avatar commented on May 23, 2024

I have the same issue on Windows 7 64bit Enterprise
yarn start

$ node ./build/main.js
module.js:472
    throw err;
    ^

Error: Cannot find module 'C:codejsproductssfi.sebn.coackendattachment
ode_modulessource-map-supportsource-map-support.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\code\js\products\sfi.sebn.com\backend\attachment\build\main.js:1:63)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
error Command failed with exit code 1.
console.log(require.resolve('source-map-support'))
// C:\code\js\products\sfi.sebn.com\backend\attachment\node_modules\source-map-support\source-map-support.js
console.log(`require('${require.resolve('source-map-support')}')`)
// require('C:\code\js\products\sfi.sebn.com\backend\attachment\node_modules\source-map-support\source-map-support.js')

package.json extract

"scripts": {
  "start": "node ./build/main.js",
  "prestart": "backpack build"
}

versions

node: '7.5.0'
yarn: '0.19.1'
backpack-core: '0.0.9'

Locally I changed https://github.com/palmerhq/backpack/blob/master/packages/backpack-core/config/webpack.config.js#L110 to banner: 'require("source-map-support/register")' as in version 0.0.8 which works as expected but now I'm out of sync with npm version ofc.

from backpack.

thierryskoda avatar thierryskoda commented on May 23, 2024

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.

from backpack.

ericclemmons avatar ericclemmons commented on May 23, 2024

I'll work on this!

from backpack.

thierryskoda avatar thierryskoda commented on May 23, 2024

Okay thanks! I will try that!

from backpack.

dortzur avatar dortzur commented on May 23, 2024

thank you @jaredpalmer Using both backpack and razzle on production systems and loving it

from backpack.

snaerth avatar snaerth commented on May 23, 2024

Has the issue been resolved

from backpack.

ChiefORZ avatar ChiefORZ commented on May 23, 2024

still having the same problem on windows 10 in both development and build.
project uses lerna and yarn workspaces.
using backpack version 0.7.0

from backpack.

idanwe avatar idanwe commented on May 23, 2024

@jalvarado91 did you solve that? we facing the same issue building docker image with multi stage

from backpack.

vivere-dally avatar vivere-dally commented on May 23, 2024

Facing the same issue. The examples provided here did not help. Any news on fixing this?

from backpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.