remix icon indicating copy to clipboard operation
remix copied to clipboard

Error: Cannot find module '@remix-run/server-runtime'

Open blasterbug opened this issue 2 years ago • 7 comments

What version of Remix are you using?

1.7.1

Steps to Reproduce

Update [email protected] to [email protected] (all relevant @remix-run/<package>.

  • npm install
  • npm run dev
  • Open the remix app in the browser

Expected Behavior

The page should load and be rendered

Remix App Server started at http://localhost:3000 (http://192.168.1.101:3000)
GET / 200 - - 100.855 ms

Actual Behavior

Remix App Server started at http://localhost:3000 (http://192.168.1.101:3000)
Error: Cannot find module '@remix-run/server-runtime'
Require stack:
- /Users/benjamin/GitHub/klientlistan/node_modules/remix-auth/build/authenticator.js
- /Users/benjamin/GitHub/klientlistan/node_modules/remix-auth/build/index.js
- /Users/benjamin/GitHub/klientlistan/build/index.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/serve/dist/index.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/dev/dist/cli/commands.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/dev/dist/cli/run.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/dev/dist/cli/index.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/dev/dist/index.js
- /Users/benjamin/GitHub/klientlistan/node_modules/@remix-run/dev/dist/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:955:15)
    at Function.Module._load (node:internal/modules/cjs/loader:803:27)
    at Module.require (node:internal/modules/cjs/loader:1021:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/benjamin/GitHub/klientlistan/node_modules/remix-auth/build/authenticator.js:4:26)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Function.Module._load (node:internal/modules/cjs/loader:838:12)
    at Module.require (node:internal/modules/cjs/loader:1021:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/benjamin/GitHub/klientlistan/node_modules/remix-auth/build/index.js:13:14)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Function.Module._load (node:internal/modules/cjs/loader:838:12)
GET / 500 - - 856.468 ms

blasterbug avatar Sep 19 '22 07:09 blasterbug

@blasterbug can you share you package.json contents ?

machour avatar Sep 19 '22 10:09 machour

By the way, the problem seems to originate from remix-auth which lists @remix-run/server-runtime as a peer dependency, so you must install it.

machour avatar Sep 19 '22 10:09 machour

Hello, I do have remix-auth install.

{
  "private": true,
  "name": "klientlistan",
  "version": "3.0.0",
  "description": "Papperslöst's Klientlistan",
  "license": "",
  "author": {
    "name": "Benjamin",
    "email": "[email protected]"
  },
  "sideEffects": false,
  "scripts": {
    "setup": "prisma migrate dev",
    "build": "run-s build:*",
    "build:css": "npm run generate:css -- --minify",
    "build:sass": "npm run generate:sass -- --style=compressed",
    "build:remix": "remix build",
    "dev": "run-p dev:*",
    "dev:css": "cross-env NODE_ENV=development npm run generate:css -- --watch",
    "dev:sass": "cross-env NODE_ENV=development npm run generate:sass -- --watch",
    "dev:remix": "cross-env NODE_ENV=development remix dev",
    "generate:css": "tailwindcss -o ./app/styles/tailwind.css",
    "generate:sass": "sass app/styles/:app/styles/",
    "start": "remix-serve build",
    "extract": "i18next -c ./i18next-parser.js 'app/**/*.{ts,tsx}'",
    "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
    "lint:fix": "npm run lint -- --fix",
    "format": "prettier --write .",
    "prettier": "prettier --ignore-path .eslintignore app",
    "check-format": "prettier -- --list-different",
    "prepare": "husky install",
    "test": "vitest",
    "coverage": "vitest run --coverage",
    "test:e2e:dev": "start-server-and-test dev http://localhost:3000 cy:open",
    "pretest:e2e:run": "npm run build",
    "test:e2e:run": "start-server-and-test start http://localhost:3000 cy:run",
    "cy:run": "cypress run",
    "cy:open": "cypress open",
    "cy:run:legacy": "cypress run --config-file cypress.legacy.json",
    "cy:open:legacy": "cypress open --config-file cypress.legacy.json",
    "typecheck": "tsc -b && tsc -b cypress",
    "validate": "run-p \"test -- --run\" lint typecheck test:e2e:run",
    "seed": "pg_restore -p 5432 -h localhost -d postgres --no-owner --role=postgres -U postgres -O -x  --clean --if-exists --single-transaction --format=custom",
    "seed:test": "pg_restore -p 5432 -h localhost -d postgres --no-owner --role=postgres -U postgres  -O -x --clean --if-exists --single-transaction --format=custom cypress/data/seed.sql",
    "docker:postgres": "docker-compose up -d postgres",
    "docker:remix:prepare": "docker volume create nodemodules",
    "docker:remix:install": "docker-compose -f docker-compose.builder.yml run --rm install",
    "docker:remix": "docker-compose up --abort-on-container-exit",
    "docker:cypress:run": "docker-compose -f ./docker-compose.cypress-run.yml up --abort-on-container-exit",
    "docker:cypress:open": "docker-compose -f ./docker-compose.cypress-run.yml -f ./docker-compose.cypress-open.yml up --abort-on-container-exit",
    "docker:down": "docker-compose down"
  },
  "dependencies": {
    "@headlessui/react": "1.7.2",
    "@heroicons/react": "2.0.11",
    "@prisma/client": "4.3.1",
    "@remix-run/node": "1.7.1",
    "@remix-run/react": "1.7.1",
    "@remix-run/serve": "1.7.1",
    "accept-language-parser": "1.5.0",
    "ag-charts-community": "6.1.3",
    "ag-charts-react": "6.1.1",
    "ag-grid-community": "26.2.1",
    "ag-grid-enterprise": "26.2.0",
    "ag-grid-react": "26.2.0",
    "async": "^3.2.4",
    "bcrypt": "5.0.1",
    "classnames": "2.3.2",
    "cypress-pipe": "^2.0.0",
    "dayjs": "1.11.5",
    "formik": "2.2.9",
    "i18next": "21.9.2",
    "i18next-browser-languagedetector": "6.1.5",
    "i18next-http-backend": "1.4.1",
    "lodash": "4.17.21",
    "nodemailer": "6.7.8",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-i18next": "11.18.6",
    "remix-auth": "3.3.0",
    "remix-auth-form": "1.2.0",
    "remix-auth-microsoft": "1.0.3",
    "remix-auth-oauth2": "1.3.0",
    "store2": "^2.14.2",
    "yup": "0.32.11"
  },
  "devDependencies": {
    "@jackfranklin/test-data-bot": "2.0.0",
    "@remix-run/dev": "1.7.1",
    "@remix-run/eslint-config": "1.7.1",
    "@tailwindcss/aspect-ratio": "^0.4.2",
    "@tailwindcss/forms": "^0.5.3",
    "@tailwindcss/line-clamp": "^0.4.2",
    "@tailwindcss/typography": "^0.5.7",
    "@testing-library/cypress": "8.0.3",
    "@testing-library/jest-dom": "5.16.5",
    "@testing-library/react": "13.4.0",
    "@testing-library/react-hooks": "8.0.1",
    "@testing-library/user-event": "14.4.3",
    "@types/accept-language-parser": "1.5.3",
    "@types/async": "^3.2.15",
    "@types/bcrypt": "5.0.0",
    "@types/nodemailer": "6.4.6",
    "@types/react": "^18.0.20",
    "@types/react-dom": "^18.0.6",
    "@typescript-eslint/eslint-plugin": "^5.37.0",
    "@typescript-eslint/parser": "^5.37.0",
    "@vitejs/plugin-react": "2.1.0",
    "arr-diff": "^4.0.0",
    "autoprefixer": "^10.4.11",
    "c8": "7.12.0",
    "cross-env": "7.0.3",
    "cypress": "^10.8.0",
    "cypress-ag-grid": "^2.0.1",
    "cypress-wait-until": "^1.7.2",
    "eslint": "^8.23.1",
    "eslint-config-prettier": "8.5.0",
    "eslint-import-resolver-typescript": "3.5.1",
    "eslint-plugin-cypress": "2.12.1",
    "eslint-plugin-prettier": "4.2.1",
    "fast-array-diff": "^1.0.1",
    "happy-dom": "6.0.4",
    "husky": "8.0.1",
    "i18next-parser": "6.5.0",
    "identity-obj-proxy": "3.0.0",
    "lint-staged": "^13.0.3",
    "npm-run-all": "4.1.5",
    "postcss": "8.4.16",
    "postcss-import": "^15.0.0",
    "prettier": "^2.7.1",
    "prettier-eslint": "15.0.1",
    "prettier-plugin-tailwindcss": "0.1.13",
    "prisma": "4.3.1",
    "sass": "1.54.9",
    "start-server-and-test": "1.14.0",
    "tailwindcss": "^3.1.8",
    "tsconfig-paths": "4.1.0",
    "typescript": "^4.8.3",
    "vite-tsconfig-paths": "3.5.0",
    "vitest": "0.23.4"
  },
  "engines": {
    "node": ">=14"
  }
}

PS: Dependabot updated the remix version and we some cypress tests in the pipeline before merging the Dependabot PR.

blasterbug avatar Sep 19 '22 11:09 blasterbug

Hello, I meant you must manually install @remix-run/server-runtime since remix-auth requires it in its peer dependencies.

/cc @sergiodxa Am I correct here?

machour avatar Sep 19 '22 11:09 machour

It is surprising because we got this exact same issue a while ago and then a new version of Remix fixed the issue,

blasterbug avatar Sep 19 '22 11:09 blasterbug

I can confirm that for remix-auth it has to be explicitely added to the app dependencies.

We've just faced this issue and it was due to our CD pipeline using npm prune --production to only keep production packages. @remix-run/server-runtime wasn't considered as one, so I think it could be the reason why you detected the issue as being fixed.

Depending on your package manager it is possible that sometimes you get the "production" packages only and sometimes not… I recommend you to look into diffs of your package lockfile to see what could have changed there.

real34 avatar Dec 30 '22 06:12 real34

@blasterbug is this still an issue for you? If so, is it fixed by explicitly requiring @remix-run/server-runtime in your package.json file?

machour avatar Jan 22 '23 20:01 machour