Docker Production Webpack 5 Build Problem

This is so painful to debug. For some reason production build works just fine in my project using Node Cmd Prompt (Windows). But as soon as you use Docker using the node Docker Image. Aurelia production build gives off a lot of failures and typescript errors during compilation.

I tried multiple versions of Webpack, multiple versions of Node (including many older versions). It’s not quite clear why it works fine to run and build prod in Cmd prompt but not within a docker image and then hosting it on nginx as an index.html. These things worked just fine in Au1 and many different articles exist online of people doing this with many other frameworks without issue

They look a lot like this (21+ errors).: (but goes on for a while)

ERROR in /app/src/components/front-page.ts
./src/components/front-page.ts 4:9-16
[tsl] ERROR in /app/src/components/front-page.ts(4,10)
      TS2614: Module '"aurelia"' has no exported member 'IRouter'. Did you mean to use 'import IRouter from "aurelia"' instead?
 @ ./src/components/index.ts 11:0-29 11:0-29
 @ ./src/my-app.ts 10:0-101 19:19-31 24:19-33 30:19-34 36:19-30 42:19-28
 @ ./src/main.ts 6:0-33 19:9-14

ERROR in /app/src/components/front-page.ts
./src/components/front-page.ts 4:18-33
[tsl] ERROR in /app/src/components/front-page.ts(4,19)
      TS2614: Module '"aurelia"' has no exported member 'IRouteViewModel'. Did you mean to use 'import IRouteViewModel from "aurelia"' instead?
 @ ./src/components/index.ts 11:0-29 11:0-29

webpack 5.88.0 compiled with 21 errors in 7392 ms
The command '/bin/sh -c npm run build' returned a non-zero code: 1

likely you are having different dependency restoration results. Maybe check your lock file to see if it’s got through properly, also your dependencies in package json whether it’s pinned to a specific version.

Note on the error: we used to export IRouter from aurelia package, but now not anymore. Hence I suspect your dependencies resolution got wacked.

1 Like

But shouldn’t deleting the package lock fix the problem? I’m able to compile prod version locally with webpack 5.88 interestingly using npm start build. I’ve tried deleting package-lock and making sure docker doesn’t copy over the package-lock like it was doing before.

I even put everything in dependencies rather than devDependencies just in case.

When you remove the lock file, it should try to recreate it with the latest should it not?

"dependencies": {
    "@aurelia/validation": "latest",
    "@aurelia/validation-html": "^2.0.0-alpha.40",
    "@aurelia/webpack-loader": "latest",
    "@aurelia/testing": "latest",
    "@aurelia/ts-jest": "latest",
    "aurelia": "latest",
    "ts-loader": "^9.3.0",
    "typescript": "^4.7.3",
    "tslib": "^2.4.0",
    "css-loader": "^6.7.1",
    "dotenv-webpack": "^7.1.0",
    "eslint": "^8.17.0",

Any of these versions look off?? I’ve mostly avoided changing anything in package.json manually.

If I check npm list:

+-- aurelia@2.0.0-alpha.40

Most of the Aurelia ones are alpha.40.

I checked npm version on docker as well vs the node I have.

What library is producing the errors? Is it just aurelia versions or typescript versions? There must be a reason why it’s working locally in cmd prompt but not in docker linux.

    "@aurelia/validation": "latest",
    "@aurelia/validation-html": "^2.0.0-alpha.40",
    "@aurelia/webpack-loader": "latest",
    "@aurelia/testing": "latest",
    "@aurelia/ts-jest": "latest",

Change to

    "@aurelia/validation": "2.0.0-alpha.40",
    "@aurelia/validation-html": "2.0.0-alpha.40",
    "@aurelia/webpack-loader": "2.0.0-alpha.40",
    "@aurelia/testing": "2.0.0-alpha.40",
    "@aurelia/ts-jest": "2.0.0-alpha.40",
1 Like

omg why didn’t I think of that. I just assumed since they are different modules that it’s ok to mix and match but that makes sense in alpha that wouldn’t be the case when there is a beta out. I also assumed modules check dependency of each others’ versions.

I should have checked aurelia - npm

You are amazing!