-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
🐛 Bug Report: Experiencing "Error: Cannot find module 'packages/backend/dist/index.cjs.js " #24808
Comments
Are you basing your build setup on https://backstage.io/docs/deployment/docker? It looks like you might've skipped the build step |
Patrick, thanks for your response. The build step is actually associated within my GitLab CI pipeline runner configuration in which the dockerfile that I added here is leveraged to pull down and install all the preqs (yarn, git, typescript, etc...) via Node.js v18.20.2 image. After that completes per the build stage, the following commands are then executed to build and push the new image with the resulting variables:
The "deploy" stage then leverage the new image per the CI_Registry and create the OpenShift service, deployment, and route configuration per yaml config files within the platform. As noted prior, I'm leveraging the "app-config.production.yaml" within my dockerfile "CMD" script to launch Backstage via production deployment which leads to the error that I'm currently experiencing. I will note that I've tested the "dev" deployment locally with the same code by running "yarn dev" and the application deployed successfully. I'm only hitting a snag when attempting to deploy via production. |
@deemanning right, but does that all use either of the docker build options outlined in https://backstage.io/docs/deployment/docker? |
I got the same issue, in my case, I had a misconfiguration on .dockerignore |
Hey Patrick, sorry for the late response. To answer your question, yes, I initially leveraged that exact article and the build options via my dockerfile config. The problem that I ran into with the documented build options was that a number of the directories associated with the build options no longer exist within the current Backstage binary file directories. The following is an example of an error that I run into with leveraging the provided build options: ERROR: failed to solve: failed to compute cache key: "/packages/backend/dist/bundle.tar.gz" not found: not found There is no "dist" directory within /packages per the download of the current Backstage application binary files. The version of Backstage that I'm leveraging is 1.27.1. So it appears that there are new code updates via the Backstage application but the documentation for Backstage deployment is not updated. Is there by chance an updated deployment doc that correlates with the 1.27.1 version? |
📜 Description
I'm currently experiencing the following when attempting to deploy Backstage via CI/CD pipeline per dockerfile leveraging a Node.js v18.20.2 image:
node:internal/modules/cjs/loader:451
throw err;
^
Error: Cannot find module '/appdir/packages/backend/dist/index.cjs.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:443:19)
at Module._findPath (node:internal/modules/cjs/loader:711:18)
at resolveMainPath (node:internal/modules/run_main:25:23)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:121:24)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
path: '/appdir/packages/backend/package.json',
requestPath: '/appdir/packages/backend'
}
Node.js v18.20.2
Within the same GitLab project, the application deploys successfully locally. Along with the image reference via FROM, the dockerfile is associated with the following config:
#Install all required utilities and packages
USER 0
RUN microdnf update -y && microdnf install -y git && microdnf install -y python3 && microdnf clean all
RUN microdnf install -y sqlite sqlite-devel && microdnf clean all
USER 1001
#Create node modules dir
USER 0
RUN mkdir -p /.cache/node/corepack/v1 && chmod -R 777 /.cache
USER 1001
#Set the specific yarn version
USER 0
RUN yarn set version 1.22.22
#Install dependencies using yarn
RUN npm install -g yarn
RUN mkdir ~/.yarn-global
RUN yarn config set prefix ~/.yarn-global
USER 1001
USER 0
RUN npm install -g typescript
RUN npm install -g npm
USER 1001
Copy app code to root
COPY --chown=1001:0 . .
EXPOSE 3000
Launch backstage app
CMD ["node", "packages/backend", "--config", "app-config.production.yaml"]
After running the following to ensure that I have the latest versions, I'm still hitting the same issue:
npx @backstage/cli versions:bump
yarn backstage-cli info
yarn run v1.22.22
OS: Darwin 23.4.0 - darwin/arm64
node: v18.20.2
yarn: 1.22.22
cli: 0.26.5 (installed)
backstage: 1.27.1
Dependencies:
@backstage/app-defaults 1.5.5
@backstage/backend-app-api 0.7.4
@backstage/backend-common 0.22.0
@backstage/backend-defaults 0.2.18
@backstage/backend-dev-utils 0.1.4
@backstage/backend-openapi-utils 0.1.11
@backstage/backend-plugin-api 0.6.18
@backstage/backend-tasks 0.5.23
@backstage/catalog-client 1.6.5
@backstage/catalog-model 1.5.0
@backstage/cli-common 0.1.13
@backstage/cli-node 0.2.5
@backstage/cli 0.26.5
@backstage/config-loader 1.8.0
@backstage/config 1.2.0
@backstage/core-app-api 1.12.5
@backstage/core-compat-api 0.2.5
@backstage/core-components 0.14.7
@backstage/core-plugin-api 1.9.2
@backstage/e2e-test-utils 0.1.1
@backstage/errors 1.2.4
@backstage/eslint-plugin 0.1.8
@backstage/frontend-plugin-api 0.6.5
@backstage/integration-aws-node 0.1.12
@backstage/integration-react 1.1.27
@backstage/integration 1.11.0
@backstage/plugin-api-docs 0.11.5
@backstage/plugin-app-backend 0.3.66
@backstage/plugin-app-node 0.1.18
@backstage/plugin-auth-backend-module-atlassian-provider 0.1.10
@backstage/plugin-auth-backend-module-aws-alb-provider 0.1.10
@backstage/plugin-auth-backend-module-azure-easyauth-provider 0.1.1
@backstage/plugin-auth-backend-module-bitbucket-provider 0.1.1
@backstage/plugin-auth-backend-module-cloudflare-access-provider 0.1.1
@backstage/plugin-auth-backend-module-gcp-iap-provider 0.2.13
@backstage/plugin-auth-backend-module-github-provider 0.1.15
@backstage/plugin-auth-backend-module-gitlab-provider 0.1.15
@backstage/plugin-auth-backend-module-google-provider 0.1.15
@backstage/plugin-auth-backend-module-guest-provider 0.1.4
@backstage/plugin-auth-backend-module-microsoft-provider 0.1.13
@backstage/plugin-auth-backend-module-oauth2-provider 0.1.15
@backstage/plugin-auth-backend-module-oauth2-proxy-provider 0.1.11
@backstage/plugin-auth-backend-module-oidc-provider 0.1.9
@backstage/plugin-auth-backend-module-okta-provider 0.0.11
@backstage/plugin-auth-backend 0.22.5
@backstage/plugin-auth-node 0.4.13
@backstage/plugin-auth-react 0.1.2
@backstage/plugin-catalog-backend-module-scaffolder-entity-model 0.1.16
@backstage/plugin-catalog-backend 1.22.0
@backstage/plugin-catalog-common 1.0.23
@backstage/plugin-catalog-graph 0.4.5
@backstage/plugin-catalog-import 0.11.0
@backstage/plugin-catalog-node 1.12.0
@backstage/plugin-catalog-react 1.12.0
@backstage/plugin-catalog 1.20.0
@backstage/plugin-events-node 0.3.4
@backstage/plugin-org 0.6.25
@backstage/plugin-permission-backend-module-allow-all-policy 0.1.15
@backstage/plugin-permission-backend 0.5.42
@backstage/plugin-permission-common 0.7.13
@backstage/plugin-permission-node 0.7.29
@backstage/plugin-permission-react 0.4.22
@backstage/plugin-proxy-backend 0.4.16
@backstage/plugin-scaffolder-backend-module-azure 0.1.10
@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.1.8
@backstage/plugin-scaffolder-backend-module-bitbucket-server 0.1.8
@backstage/plugin-scaffolder-backend-module-bitbucket 0.2.8
@backstage/plugin-scaffolder-backend-module-gerrit 0.1.10
@backstage/plugin-scaffolder-backend-module-gitea 0.1.8
@backstage/plugin-scaffolder-backend-module-github 0.2.8
@backstage/plugin-scaffolder-backend-module-gitlab 0.4.0
@backstage/plugin-scaffolder-backend 1.22.6
@backstage/plugin-scaffolder-common 1.5.2
@backstage/plugin-scaffolder-node 0.4.4
@backstage/plugin-scaffolder-react 1.8.5
@backstage/plugin-scaffolder 1.20.0
@backstage/plugin-search-backend-module-catalog 0.1.24
@backstage/plugin-search-backend-module-techdocs 0.1.23
@backstage/plugin-search-backend-node 1.2.22
@backstage/plugin-search-backend 1.5.8
@backstage/plugin-search-common 1.2.11
@backstage/plugin-search-react 1.7.11
@backstage/plugin-search 1.4.11
@backstage/plugin-techdocs-backend 1.10.5
@backstage/plugin-techdocs-module-addons-contrib 1.1.10
@backstage/plugin-techdocs-node 1.12.4
@backstage/plugin-techdocs-react 1.2.4
@backstage/plugin-techdocs 1.10.5
@backstage/plugin-user-settings 0.8.6
@backstage/release-manifests 0.0.11
@backstage/repo-tools 0.9.0
@backstage/test-utils 1.5.5
@backstage/theme 0.5.4
@backstage/types 1.1.1
@backstage/version-bridge 1.0.8
👍 Expected behavior
Successful deployment via CI/CD pipeline deployment
👎 Actual Behavior with Screenshots
👟 Reproduction steps
Details are provided within the description.
📃 Provide the context for the Bug.
No response
🖥️ Your Environment
No response
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Code of Conduct?
Are you willing to submit PR?
None
The text was updated successfully, but these errors were encountered: