remix: import_jsx_dev_runtime.jsxDEV is not a function after upgrade to 1.7.0 in Docker Container

What version of Remix are you using?

1.7.0

Steps to Reproduce

After upgrading to 1.7.0 and building my docker container, Going to any page yields import_jsx_dev_runtime.jsxDEV is not a function on the server, and an error page is rendered.

Here is my Docker file that causes it to fail:

# Base Node image
FROM node:lts-alpine as base

# Setup all node_modules
FROM base as deps

RUN mkdir /app
WORKDIR /app

ADD package.json ./
ADD yarn.lock ./
RUN yarn install --production=false

# Setup production node_modules
FROM base as production-deps

RUN mkdir /app
WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules
ADD package*.json ./

# Build the app
FROM base as build

ENV NODE_ENV=production

RUN mkdir /app
WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

ADD . .
RUN yarn run build

# Build production image
FROM base

RUN mkdir /app
WORKDIR /app

COPY --from=production-deps /app/node_modules /app/node_modules

COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
ADD . .

EXPOSE 3000

CMD ["yarn", "start"]

It is only failing in the container, running the app even with remix-serve works correctly. All package.json dependencies are locked in.

Expected Behavior

The app should work as it did before the upgrade to 1.7.0 (Release notes said no changes to code necessary).

Actual Behavior

The app fails to render any pages.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 48
  • Comments: 59 (5 by maintainers)

Commits related to this issue

Most upvoted comments

this happens out-of-the box with the following steps:

  1. run npx create-remix@latest (1.16.1 at time of writing)
  2. choose Just the basics
  3. choose Netlify
  4. choose Typescript
  5. choose “yes” to install npm deps
  6. run nvm use 16
  7. open project and run NODE_ENV=production npm run build
  8. run npm run start

opening browser shows the following:

Screenshot 2023-05-27 at 21 30 26

server log
TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function
  at /Users/jenna/Development/remix-netlify/app/entry.server.tsx:89:7
  at new Promise (<anonymous>)
  at handleBrowserRequest (/Users/jenna/Development/remix-netlify/app/entry.server.tsx:87:10)
  at handleRequest (/Users/jenna/Development/remix-netlify/app/entry.server.tsx:31:7)
  at handleDocumentRequestRR (/Users/jenna/Development/remix-netlify/node_modules/@remix-run/server-runtime/dist/server.js:215:20)
  at processTicksAndRejections (node:internal/process/task_queues:95:5)
  at requestHandler (/Users/jenna/Development/remix-netlify/node_modules/@remix-run/server-runtime/dist/server.js:49:18)
  at Object.<anonymous> (/Users/jenna/Development/remix-netlify/node_modules/@remix-run/netlify/dist/server.js:35:20)
Response with status 500 in 5 ms.

I’m getting this error now after upgrading to 1.12.0. No docker, this is macos dev env. Upgraded and setup to run new dev env with concurrent TW, remix dev & nodemon:

concurrently \"npm run dev:css\" \"remix dev\" \"nodemon ./server.js\"

Everything builds, but I get this same error of

TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function

Only way I can actually get project to render without error now is to run:

npm run build
npm run start

This at least allows me to still view the project.

I’ve tried

  1. removing build/**/*, public/build/**/*, .cache/**/* and rebuilding.
  2. removing package-lock.json and running npm i -f
  3. removing node_modules/**/* && package-lock.json and running npm i
  4. All of the above with <LiveReload /> in root.tsx && the same commented out

The error still occurs. Essentially I can no longer use npm run dev, I need to build and start to view project.

I don’t know if it is helpful, but I experienced the same error and solved it in this mode:

  • make sure you don’t copy the “builds” folders to the container, adding the relevant paths to the .dockerignore file:
build
public/build
  • also copy the package-lock.json file to ensure that the same versions of the packages used in the development environment are installed. The command in the Dockerfile:

ADD package.json package-lock.json ./

Version:


"@remix-run/react": "^1.8.1",
"@remix-run/serve": "^1.8.1",
"@remix-run/vercel": "^1.8.1",
"@remix-run/dev": "^1.8.1",
"@remix-run/eslint-config": "^1.8.1",

"esbuild": "version": "0.15.12",

I’m seeing this with 1.7.2, however if I run remix build before remix-serve it starts up.

Then if I run remix dev, it will cause my next remix-serve to throw the TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function error until I run remix build again.

I’m getting the same error when I deploy it to fly.io and visit the deployed app. Happens on a fresh remix install and deploy of this PWA remix stack - https://github.com/ShafSpecs/rockspec-stack

@lukaszdz i noticed you have a .dockerignore with just node_modules, can you try adding build and public/build to that? in theory running npm run build should alleviate that, but perhaps not

I’m getting it when deploying to fly.io. Local dev appears to be working fine, as soon as I deployed it app stopped loading and this is in the logs:

2022-09-13T10:20:03.887 app[2d96f538] ewr [info] at handleRequest (/app/app/entry.server.tsx:23:9)
2022-09-13T10:20:03.887 app[2d96f538] ewr [info] at handleDocumentRequest (/app/node_modules/@remix-run/server-runtime/dist/server.js:409:20)
2022-09-13T10:20:03.887 app[2d96f538] ewr [info] at requestHandler (/app/node_modules/@remix-run/server-runtime/dist/server.js:49:18)
2022-09-13T10:20:03.887 app[2d96f538] ewr [info] at /app/node_modules/@remix-run/express/dist/server.js:39:22

Seeing the same thing in 1.7.6

Solved by rm -rf build folder and then running the build script again.

Seeing the same thing as @jgentes in 1.7.5

Is there a good reason why remix-serve hard-codes NODE_ENV=production?

production mode sounds like a reasonable default, but would it hurt to allow us to explicitly set it to different values (for whatever reason?)

Asking because I have/had reasons, and then things just stopped working once I upgraded from version 1.6.*

We managed to fix the issue by forcing esbuild to ^0.15.8 (resolutions field in package.json). Now running remix 1.7.2.

@yehudamakarov is this locally or on some CI? if locally, try adding public/build, build, and .cache to your .dockerignore

#6964 solves this from happening

It was happening in my case because I had the wrong value in the NODE_ENV env variable. The value should be development and production when deployed. I had it in capital letters and that’s why it was breaking the app.

For me this issue happened after uninstall some packages. npm install then npm run dev fixed the issue.

I also came across this issue today but in a slightly different format.

I’ve built with NODE_ENV=development env, but when I tried to execute the built server with NODE_ENV=production, it failed with the same issue mentioned in the description.

Reverting @remix-run/dev to 1.6.8 solves this.

Adding remix build before running the app worked for me:

"dev": "remix build && run-p dev:*",
"dev:node": "cross-env NODE_ENV=development nodemon ./server.js --watch ./server.js",
"dev:remix": "npm run clean && npm run partytown && remix watch",

@dusty @wladiston both of your issues are an upstream issue with esbuild (which has since been fixed in 0.15.8) https://github.com/evanw/esbuild/issues/2534 - i’ll be looking into upgrading our dependency next week

I was able to do it locally, as in remix build and then remix start. I’ll make sure that I’ll run a clean build tomorrow or monday.

ok, i did get this, but on 1.6.8 oddly enough

edit: oh duh semver ranges 🤦 - i think that may be the root of the issue.

edit 2: actually is this happening just locally or also when you deploy? Make sure you have a .dockerignore so that it doesn’t also copy old build files (or node modules), a copy of .gitignore should do.

i can’t reproduce 😦

https://github.com/mcansh/simple-docker-test

you could try nuking node_modules as well as your assetsBuildDirectory and serverBuildPath