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

import_jsx_dev_runtime.jsxDEV is not a function after upgrade to 1.7.0 in Docker Container #4081

Closed
mattoni opened this issue Aug 26, 2022 · 59 comments

Comments

@mattoni
Copy link

mattoni commented Aug 26, 2022

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.

@jfstn
Copy link

jfstn commented Aug 26, 2022

I came across this issue today while updating remix.
It seems to be related to the changes introduced in #3860.
For now, I'm keeping @remix/dev on version 1.6.8 and using the other @remix/* dependencies on version 1.7.0

@mcansh
Copy link
Collaborator

mcansh commented Aug 26, 2022

i haven’t seen this in any of my testing thus far, i might be able to take a look tomorrow, but for sure on Monday.

@mcansh
Copy link
Collaborator

mcansh commented Aug 27, 2022

i can't reproduce :(

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

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

@mcansh
Copy link
Collaborator

mcansh commented Aug 27, 2022

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.

@jfstn
Copy link

jfstn commented Aug 27, 2022

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.

@chrisvariety
Copy link

chrisvariety commented Aug 28, 2022

Not sure why, but this reproduces handily on a stock blues stack while running npm run test:e2e:run. Normal npm run dev does not reproduce it.

Repro steps are:

npx create-remix --template remix-run/blues-stack (answer yes to everything, select TypeScript)
npm run docker
npm run setup
npm run build
npm run test:e2e:run
workspace/src/my-remix-app ❯ node --version
v14.18.1
workspace/src/my-remix-app ❯ npm --version
6.14.15

(seems to repro on node v16 as well)

@jonschlinkert
Copy link

We're getting a similar error with 1.7.0. I haven't looked at the code in 1.7.0 vs 1.6.8 but it seems that RemixServer is exported differently in 1.7.0 than in 1.6.8.

import { RemixServer } from '@remix-run/react';
console.log(RemixServer) //=> undefined

In 1.6.8, RemixServer is a function.

This is the error we're getting:

Remix App Server started at http://localhost:3000 (http://192.168.1.122:3000)
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at entry.server.tsx:18.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
 ...

@FlatMapIO
Copy link

We're getting a similar error with 1.7.0. I haven't looked at the code in 1.7.0 vs 1.6.8 but it seems that RemixServer is exported differently in 1.7.0 than in 1.6.8.

import { RemixServer } from '@remix-run/react';
console.log(RemixServer) //=> undefined

In 1.6.8, RemixServer is a function.

This is the error we're getting:

Remix App Server started at http://localhost:3000 (http://192.168.1.122:3000)
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at entry.server.tsx:18.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
 ...

The cause of the problem has been found: #4080 (comment)

@jfstn
Copy link

jfstn commented Aug 30, 2022

@FlatMapIO the problem does not seem to be precisely the same. I tried all those solutions and they don't seem to work.

@chrisvariety
Copy link

yep, React.jsx: type is invalid is an entirely different problem, not relevant to this issue.

@CanRau
Copy link
Contributor

CanRau commented Aug 31, 2022

Hmm weird I'm sure I upgraded couple of days ago and just now ran into this issue 🤨
Also experimenting on another project I briefly ran into it, but resolved it by changing a custom transform stream

Downgrading to 1.6.8 seems to have solved it for now

@davidlukerice
Copy link

davidlukerice commented Sep 1, 2022

Odd. I also ran into this today when starting up my local dev server for the first time in a few days. Been on 1.7.0 for a while now, though. So not sure what's changed.

Edit:
Got mine running again after doing a full clear of the current modules, re-building the app, then rerunning the local server.
I also went ahead and bumped a number of out of date libraries while I was at it.

rm -rf node_modules/
rm package-lock.json
npm cache clear --force
npm i
npm build
npm start / npm run dev

@jfstn
Copy link

jfstn commented Sep 2, 2022

Just tried a clean build, with a clean package manager and docker cache. The problem is still there for me.

@mcansh
Copy link
Collaborator

mcansh commented Sep 2, 2022

Just tried a clean build, with a clean package manager and docker cache. The problem is still there for me.

is your repo public? or can you try to reproduce on a fresh npx [email protected]?

@CanRau
Copy link
Contributor

CanRau commented Sep 2, 2022

Uh to clarify to me it happened running dev on my machine, so no Docker required 😅

But since last time it didn't happen again 🤷🏻‍♂️

@jfstn
Copy link

jfstn commented Sep 2, 2022

Just tried a clean build, with a clean package manager and docker cache. The problem is still there for me.

is your repo public? or can you try to reproduce on a fresh npx [email protected]?

This only happens with remix-run/dev 1.7.0

@chrisvariety
Copy link

Just tried a clean build, with a clean package manager and docker cache. The problem is still there for me.

is your repo public? or can you try to reproduce on a fresh npx [email protected]?

public repo reproduction steps are here #4081 (comment) (as mentioned, doesn't repro on 1.6.8)

@dusty
Copy link

dusty commented Sep 2, 2022

I'm having a similar problem, getting an error TypeError: (0 , import_react.useFetcher) is not a function\n that I'm seeing in the ErrorBoundary.

However, I am having a really hard time reproducing it on a minimal repro. Also, tried clearing out node_modules, cache, build, etc.. My app works fine on 1.6.8, not on 1.7.0.

yarn dev
node 18.7
macos 12.5.1

@wladpaiva
Copy link
Contributor

This is not particular to the @remix-run/dev. I'm experiencing the same issue on my vercel environment as well.

Vercel:
Screen Shot 2022-09-12 at 4 13 56 PM

Local:
Screen Shot 2022-09-12 at 4 15 44 PM

@InTheCloudDan
Copy link

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

@eseyfert
Copy link

Ran into the same issue. Runs without issues locally, but then end up seeing the import_jsx_dev_runtime.jsxDEV is not a function error in our Cypress tests GitHub workflows. Reverting to @remix-run/[email protected] fixed that issue, so something is up.

@arnemolland
Copy link

This is blocking us from upgrading our production apps as well; runs fine on local machines but the production builds running in containers are all encountering this on >1.7.0. Happens both the default express-based Remix App Server and deno runtimes.

@krivaten
Copy link

krivaten commented Sep 23, 2022

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

Same thing here. I'm able to reproduce it running remix-serve build locally as well. Even running npx [email protected] and selecting the bare bones Fly setup, I get the error.

@mcansh
Copy link
Collaborator

mcansh commented Sep 23, 2022

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

@dusty
Copy link

dusty commented Sep 24, 2022

Thanks for the followup @mcansh . We recently tried out 1.7.2 while moving all the keys above spreads and all is well for us.

@krivaten
Copy link

Thanks @mcansh. Using an npm-shrinkwrap.json I've confirmed that updating esbuild to 0.14.50 resolves the problem.

@egorpavlikhin
Copy link

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",

@arnemolland
Copy link

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

@kemicofa
Copy link

kemicofa commented Nov 28, 2022

Seeing the same thing in 1.7.6

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

@lildesert
Copy link

Hi!
Do we have an ETA on when this PR will be merged?
My cypress tests run in dev but fail in CI because of this (with NODE_ENV=test).

@xargr
Copy link

xargr commented Dec 10, 2022

I got the same TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function with version 1.8.2

@lanzoninicola
Copy link

lanzoninicola commented Dec 10, 2022

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",

@brandonpsmith

This comment was marked as duplicate.

@mcansh
Copy link
Collaborator

mcansh commented Dec 12, 2022

same 😞

Screen Shot 2022-12-12 at 1 22 42 AM

looks like it built with development mode, remix-serve will force set NODE_ENV=production so import_jsx_dev_runtime.jsxDEV won't exist, instead it would need to be import_jsx_dev_runtime.jsx - i'd check to see if you have a lingering NODE_ENV in your shell setup

@brandonpsmith
Copy link

i'd check to see if you have a lingering NODE_ENV in your shell setup

Yep. That was my issue. Lingering env. @xargr make sure you do not have NODE_ENV set to development when you run build. Build with NODE_ENV=production then npm start. Thank you @mcansh

@maranomynet
Copy link

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.*

@tsdevau
Copy link

tsdevau commented Feb 1, 2023

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.

@cjbland
Copy link

cjbland commented Feb 18, 2023

For what it's worth, I'm using 1.13.0 and I ran into this issue when I was explicitly setting NODE_ENV to something other than "production". Specifically running something like this: NODE_ENV="development" npm run build && npm run start. The console looks like this for me:

$> NODE_ENV="development" npm run build

> build
> npm run build:css && remix build


> build:css
> tailwindcss -o ./app/tailwind.css


Rebuilding...

Done in 340ms.
Building Remix app in development mode...
Built in 671ms
$> npm start
Remix App Server started at http://localhost:3000 (http://192.168.3.60:3000)
TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function
    at handleRequest (/myproject/build/index.js:50:55)
    at handleDocumentRequestRR (/myproject/node_modules/@remix-run/server-runtime/dist/server.js:229:20)
    at requestHandler (/myproject/node_modules/@remix-run/server-runtime/dist/server.js:67:18)
    at /myproject/node_modules/@remix-run/express/dist/server.js:39:22
GET / 500 - - 23.433 ms

Changing "development" to "production" and everything works as expected.

@qianjiachun
Copy link

remix 1.9.0
no docker
Debian GNU/Linux 11 x86_64

I may encounter this problem accidentally. Here is my solution (temporary)

  1. Upload the entire source code directory to the server, except for 'build', 'public' and 'node_ modules`
  2. npm i
  3. npm run build
  4. npm run start
  5. Delete the source code, leaving only build public package. json package-lock. json
  6. Upload the compiled file again in the future, and the webpage will not report errors again

My other servers have never had such problems (upload the build file can run), but this server can't.
I don't know why. It works anyway.😂

here is my package.json

{
  "private": true,
  "sideEffects": false,
  "scripts": {
    "build": "run-s build:*",
    "build:css": "npm run generate:css -- --minify",
    "build:remix": "remix build",
    "dev": "run-p dev:*",
    "dev:css": "npm run generate:css -- --watch",
    "dev:remix": "remix dev",
    "generate:css": "npx tailwindcss -i ./styles/tailwind.css -o ./app/styles/tailwind.css",
    "dev:sass": "sass --no-source-map --style compressed --watch styles/:app/styles/",
    "build:sass": "sass --no-source-map --style compressed styles/:app/styles/",
    "start": "export PORT=7003 && remix-serve build",
    "lint:eslint": "eslint --cache --max-warnings 0 \"app/**/*.{vue,js,ts,tsx}\" --fix",
    "lint:prettier": "prettier --write  \"app/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
    "lint": "npm run lint:eslint && npm run lint:prettier",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@ant-design/icons": "^4.8.0",
    "@remix-run/node": "^1.9.0",
    "@remix-run/react": "^1.9.0",
    "@remix-run/serve": "^1.9.0",
    "@types/nprogress": "^0.2.0",
    "@typescript-eslint/eslint-plugin": "^5.47.0",
    "@typescript-eslint/parser": "^5.47.0",
    "@uiw/react-watermark": "^0.0.5",
    "antd": "^4.24.3",
    "await-to-js": "^3.0.0",
    "axios": "^1.2.1",
    "browserlist": "^1.0.1",
    "clsx": "^1.2.1",
    "copy-to-clipboard": "^3.3.3",
    "dayjs": "^1.11.7",
    "echarts-stat": "^1.2.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.31.11",
    "immer": "^9.0.16",
    "npm-check": "^6.0.1",
    "nprogress": "^0.2.0",
    "prettier": "^2.8.1",
    "pure-md5": "^0.1.14",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-google-recaptcha-v3": "^1.10.1",
    "ulid": "^2.3.0",
    "use-immer": "^0.8.1"
  },
  "devDependencies": {
    "@remix-run/dev": "^1.9.0",
    "@remix-run/eslint-config": "^1.9.0",
    "@types/react": "^18.0.26",
    "@types/react-dom": "^18.0.9",
    "concurrently": "^7.6.0",
    "eslint": "^8.30.0",
    "npm-run-all": "^4.1.5",
    "patch-package": "^6.5.0",
    "sass": "^1.57.1",
    "tailwindcss": "^3.2.4",
    "typescript": "^4.9.4"
  },
  "engines": {
    "node": ">=14"
  }
}

@eran-or
Copy link

eran-or commented Feb 23, 2023

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

@cjoecker
Copy link

cjoecker commented Mar 1, 2023

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.

@kyeotic
Copy link

kyeotic commented Mar 18, 2023

I'm running into this as well, but can recreate it without docker as long as I run with ``NODE_ENV=production node server.js`.

However, if I build with NODE_ENV=production and run without that flag I don't hit the jsxDEV is not a function error. The page renders, and then throws this LiveReload error (which makes sense, it thinks we are in dev)

Warning: Expected server HTML to contain a matching <script> in <body>.
script
LiveReload2@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:7712:59
body
html
Root
RemixRoute@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:6987:20
RenderedRoute@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:4475:7
RenderErrorBoundary@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:4831:9
Routes@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:4706:7
Router@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:4657:7
RouterProvider@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:4604:7
RemixErrorBoundary@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:6604:5
RemixBrowser@http://localhost:3000/build/_shared/chunk-ZVKXYPQ3.js:8147:55

Either way, it seems building for production is still broken. Seems like the PR fix has stalled.

@VerioN1
Copy link

VerioN1 commented Mar 20, 2023

I am using the latest remix (1.14.3) on docker.
same error thrown when I run the Image, and I didn't change the NODE_ENV from 'production' .
image

@lukaszdz
Copy link

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

I'm not sure if this is related, but I'm getting the same error when I deploy it to fly.io. Happens on a fresh install and fresh deploy of this PWA remix stack - https://github.com/ShafSpecs/rockspec-stack

$ fly logs -a my-app-staging

Waiting for logs...

2023-03-29T21:12:49.233 runner[8a81e785] sjc [info] Starting instance
2023-03-29T21:12:49.354 runner[8a81e785] sjc [info] Configuring virtual machine
2023-03-29T21:12:49.356 runner[8a81e785] sjc [info] Pulling container image
2023-03-29T21:12:54.625 runner[8a81e785] sjc [info] Unpacking image
2023-03-29T21:13:01.167 runner[8a81e785] sjc [info] Preparing kernel init
2023-03-29T21:13:01.545 runner[8a81e785] sjc [info] Configuring firecracker
2023-03-29T21:13:02.342 runner[8a81e785] sjc [info] Starting virtual machine
2023-03-29T21:13:02.655 app[8a81e785] sjc [info] Starting init (commit: 8e03fa6)...
2023-03-29T21:13:02.680 app[8a81e785] sjc [info] Preparing to run: `docker-entrypoint.sh npm run start` as root
2023-03-29T21:13:02.706 app[8a81e785] sjc [info] 2023/03/29 21:13:02 listening on [fdaa:0:44ae:a7b:b2e2:8a81:e785:2]:22 (DNS: [fdaa::3]:53)
2023-03-29T21:13:03.453 app[8a81e785] sjc [info] > start
2023-03-29T21:13:03.453 app[8a81e785] sjc [info] > remix-serve build
2023-03-29T21:13:04.297 health[8a81e785] sjc [warn] Health check on port 8080 is in a 'warning' state. Your app may not be responding properly. Services exposed on ports [80, 443] may have intermittent failures until the health check passes.
2023-03-29T21:13:04.424 app[8a81e785] sjc [info] Remix App Server started at http://localhost:8080 (http://172.19.70.138:8080)
2023-03-29T21:13:10.060 health[8a81e785] sjc [info] Health check on port 8080 is now passing.
2023-03-29T21:23:54.660 app[8a81e785] sjc [info] TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function
2023-03-29T21:23:54.660 app[8a81e785] sjc [info] at handleRequest (/app/app/entry.server.tsx:13:5)
2023-03-29T21:23:54.660 app[8a81e785] sjc [info] at handleDocumentRequestRR (/app/node_modules/@remix-run/server-runtime/dist/server.js:229:20)
2023-03-29T21:23:54.660 app[8a81e785] sjc [info] at requestHandler (/app/node_modules/@remix-run/server-runtime/dist/server.js:67:18)
2023-03-29T21:23:54.660 app[8a81e785] sjc [info] at /app/node_modules/@remix-run/express/dist/server.js:39:22
2023-03-29T21:23:54.667 app[8a81e785] sjc [info] GET / 500 - - 69.908 ms
2023-03-29T21:23:58.762 app[8a81e785] sjc [info] TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function
2023-03-29T21:23:58.762 app[8a81e785] sjc [info] at handleRequest (/app/app/entry.server.tsx:13:5)
2023-03-29T21:23:58.762 app[8a81e785] sjc [info] at handleDocumentRequestRR (/app/node_modules/@remix-run/server-runtime/dist/server.js:229:20)
2023-03-29T21:23:58.762 app[8a81e785] sjc [info] at requestHandler (/app/node_modules/@remix-run/server-runtime/dist/server.js:67:18)
2023-03-29T21:23:58.762 app[8a81e785] sjc [info] at /app/node_modules/@remix-run/express/dist/server.js:39:22
2023-03-29T21:23:58.763 app[8a81e785] sjc [info] GET / 500 - - 4.490 ms

@mcansh
Copy link
Collaborator

mcansh commented Mar 30, 2023

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

@VerioN1
Copy link

VerioN1 commented Apr 1, 2023

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

helped to fix !

gmpify added a commit to Shopify/shopify-app-template-remix that referenced this issue Apr 28, 2023
`NODE_ENV=production` is required due remix issue remix-run/remix#4081

Once that issue is solved, we should be able to remove the NODE_ENV setting from here.
@jjenzz
Copy link

jjenzz commented May 27, 2023

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.

@inssein
Copy link

inssein commented Jun 19, 2023

This is a pretty real problem. I created a brand new remix app, just the basics, served by Remix App Server and using typescript.

remix run start doesn't even work without first running npm run dev, and the second run I get the error described in this thread.

Edit: Looks like I missed some instructions to run npm run build first, my bad.

@b-goldney
Copy link

b-goldney commented Jul 26, 2023

I was able to fix this issue by changing the node version to >16 in package.json.

  "engines": {
    "node": ">=16"
  }

@MichaelDeBoey
Copy link
Member

#6964 solves this from happening

@yehudamakarov
Copy link

Hey all, I'm just trying to dockerize a new remix project and running into this exact issue.

I've read everything briefly, but what must I do to dockerize my remix app?

Is the only option to downgrade everything to 1.6.8/1.7?

# base node image
FROM node:16-bullseye-slim as base

# Install all node_modules, including dev dependencies
FROM base as deps

RUN mkdir /app
WORKDIR /app

ADD package.json package-lock.json ./

RUN npm install --production=false

# Setup production node_modules
FROM base as production-deps

ENV NODE_ENV production

RUN mkdir /app
WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules
ADD package.json package-lock.json ./
RUN npm prune --production

# Build the app
FROM base as build

RUN mkdir /app
WORKDIR /app

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

ADD . .
RUN npm run build

# Finally, build the production image with minimal footprint
FROM base

ENV NODE_ENV production

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 ["npm", "run", "start"]
    "@remix-run/node": "^1.19.1",
    "@remix-run/react": "^1.19.1",
    "@remix-run/serve": "^1.19.1",
    "@remix-run/server-runtime": "^1.19.1",
    "remix": "^1.19.1",
    "@remix-run/dev": "^1.19.1",

@mcansh
Copy link
Collaborator

mcansh commented Aug 17, 2023

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

@yehudamakarov
Copy link

yehudamakarov commented Aug 17, 2023

  • that worked, (will read the thread more carefully as to why)
  • @mcansh as of now i'm just testing my container locally, but soon I'll probably set up CI
    let's say I use CI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.