Skip to content
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

Build nextJS app issue - Cannot read properties of null (reading 'message') #23162

Open
1 of 4 tasks
anteqkois opened this issue May 3, 2024 · 3 comments
Open
1 of 4 tasks
Assignees
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@anteqkois
Copy link

Current Behavior

When i build locally app, usign nx run web:build all works fine. But when I build docker image anr run RUN npx nx run web:build a got a misleading error:

332.1 ƒ Middleware                             40.3 kB
332.1
332.1 ○  (Static)   prerendered as static content
332.1 λ  (Dynamic)  server-rendered on demand using Node.js
332.1
332.8
332.8
332.8
332.8  NX   Successfully ran target build for project web and 2 tasks it depends on
332.8
332.8
332.8
332.8  NX   Cannot read properties of null (reading 'message')
332.8
332.8 Pass --verbose to see the stacktrace.
332.8
------
failed to solve: process "/bin/sh -c npx nx run web:build ${BUILD_FLAG}" did not complete successfully: exit code: 1

So I see that NextJS app was built, but the error broke my image build

Expected Behavior

No error durning docker build

GitHub Repo

No response

Steps to Reproduce

  1. create docker image and build it

Nx Report

Node   : 20.11.1
OS     : darwin-arm64
pnpm   : 8.15.2

nx (global)        : 18.3.4
nx                 : 18.3.4
@nx/js             : 18.3.4
@nx/jest           : 18.3.4
@nx/eslint         : 18.3.4
@nx/workspace      : 18.3.4
@nx/cypress        : 18.3.4
@nx/esbuild        : 18.3.4
@nx/eslint-plugin  : 18.3.4
@nx/nest           : 18.3.4
@nx/next           : 18.3.4
@nx/node           : 18.3.4
@nx/react          : 18.3.4
@nrwl/tao          : 18.3.4
@nx/web            : 18.3.4
@nx/webpack        : 18.3.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/cypress/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/webpack/plugin

Failure Logs

No response

Package Manager Version

pnpm 8.15.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Here is my docker file:

FROM linkerry-base:base AS builder

ARG NODE_ENV
ARG BUILD_FLAG

WORKDIR /app/builder

# comment this step now, project files alreaady exists
# COPY . .

RUN npx nx run web:build ${BUILD_FLAG}

FROM linkerry-base:base

WORKDIR /app
COPY --from=builder /app/builder ./
ENV NODE_ENV=$NODE_ENV

CMD ["nx", "run", "web:start"]
@anteqkois
Copy link
Author

This issue also occurs when u build docker image for my nestJS app

@Malagari
Copy link

Malagari commented May 7, 2024

I had this issue when migrating to a newer version of NX (unsure if related) and found that force disabling the NX Daemon in my Dockerfile solved my issue: ENV NX_DAEMON=false

@gcko
Copy link

gcko commented May 8, 2024

For all you folks who are searching the web for Cannot read properties of null (reading 'message') and pulling your hair out because your CI builds all of the sudden began failing:

The latest Gitlab update to Version 17 breaks NX's is-ci. I don't know why as the CI and GITLAB_CI variables are still provided FWIW, but it breaks 🤷

Adding ENV NX_DAEMON=false to your Dockerfile will fix it, thanks @Malagari !

EDIT: Looking at the latest changes to the is-ci package, it may be due to this change: packages/nx/src/utils/is-ci.ts

@FrozenPandaz FrozenPandaz added the scope: nextjs Issues related to NextJS support for Nx label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

5 participants