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)
this happens out-of-the box with the following steps:
npx create-remix@latest(1.16.1 at time of writing)Just the basicsNetlifyTypescriptnvm use 16NODE_ENV=production npm run buildnpm run startopening browser shows the following:
server log
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 functionOnly way I can actually get project to render without error now is to run:
This at least allows me to still view the project.
I’ve tried
build/**/*,public/build/**/*,.cache/**/*and rebuilding.package-lock.jsonand runningnpm i -fnode_modules/**/*&&package-lock.jsonand runningnpm i<LiveReload />in root.tsx && the same commented outThe 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:
.dockerignorefile:package-lock.jsonfile to ensure that the same versions of the packages used in the development environment are installed. The command in theDockerfile:ADD package.json package-lock.json ./Version:
I’m seeing this with
1.7.2, however if I runremix buildbeforeremix-serveit starts up.Then if I run
remix dev, it will cause my nextremix-serveto throw theTypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a functionerror until I runremix buildagain.@lukaszdz i noticed you have a
.dockerignorewith justnode_modules, can you try addingbuildandpublic/buildto that? in theory runningnpm run buildshould alleviate that, but perhaps notI’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:
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-servehard-codesNODE_ENV=production?productionmode 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.cacheto your.dockerignore#6964 solves this from happening
It was happening in my case because I had the wrong value in the
NODE_ENVenv variable. The value should bedevelopmentandproductionwhen 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=developmentenv, but when I tried to execute the built server withNODE_ENV=production, it failed with the same issue mentioned in the description.Reverting
@remix-run/devto1.6.8solves this.Adding
remix buildbefore running the app worked for me:@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 buildand thenremix 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 enoughedit: 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
.dockerignoreso that it doesn’t also copy old build files (or node modules), a copy of.gitignoreshould do.i can’t reproduce 😦
https://github.com/mcansh/simple-docker-test
you could try nuking
node_modulesas well as yourassetsBuildDirectoryandserverBuildPath