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

Blitz app setup not working with 2.0.0-beta.34 #4236

Closed
SilvanVerhoeven opened this issue Oct 16, 2023 · 7 comments · Fixed by #4237 · May be fixed by #4405
Closed

Blitz app setup not working with 2.0.0-beta.34 #4236

SilvanVerhoeven opened this issue Oct 16, 2023 · 7 comments · Fixed by #4237 · May be fixed by #4405
Labels
kind/bug Something isn't working status/done

Comments

@SilvanVerhoeven
Copy link

SilvanVerhoeven commented Oct 16, 2023

What is the problem?

After creating a new app with blitz new <name> and running blitz dev, the startup fails with the MODULE_NOT_FOUND error below. The creation itself seems uneventful (see further logs below).

Paste all your error logs here:

✔ Next.js was successfully patched with a React Suspense fix
✔ Routes manifest was successfully generated
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- error Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Cannot find module 'next/dist/client/resolve-href'
Require stack:
- /home/<Project Directory>/node_modules/@blitzjs/next/dist/index-server.cjs
- /home/<Project Directory>/next.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /home/<Project Directory>/node_modules/next/dist/server/require-hook.js:189:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/home/<Project Directory>/node_modules/@blitzjs/next/dist/index-server.cjs:8:21)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12) {
  type: 'Error',
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/<Project Directory>/node_modules/@blitzjs/next/dist/index-server.cjs',
    '/home/<Project Directory>/next.config.js'
  ]
}

Paste all relevant code snippets here:

yarn global add blitz
blitz new test
cd test
blitz dev

What are detailed steps to reproduce this?

  1. (Optional, also does not work in new directory: Clone a basic GitHub repository (only a README.md and a LICENSE.md) into my-app)
  2. Install latest blitz version (2.0.0-beta.34) with yarn global add blitz
  3. blitz new my-app
  4. cd my-app
  5. blitz dev

Run blitz -v and paste the output here:

Blitz version: 2.0.0-beta.34 (global)
Blitz version: 2.0.0-beta.34 (local)
Linux 5.10 | linux-x64 | Node: v18.17.0


 Package manager: npm

  System:
    OS: Linux 5.10 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 21.37 GB / 24.85 GB
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.17.0 - ~/.nvs/default/bin/node
    Yarn: 1.22.19 - ~/.nvs/default/bin/yarn
    npm: 9.6.7 - ~/.nvs/default/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.34 => 2.0.0-beta.34 
    @blitzjs/next: 2.0.0-beta.34 => 2.0.0-beta.34 
    @blitzjs/rpc: 2.0.0-beta.34 => 2.0.0-beta.34 
    @prisma/client: 4.6.1 => 4.6.1 
    blitz: 2.0.0-beta.34 => 2.0.0-beta.34 
    next: 13.4.5 => 13.4.5 
    prisma: 4.6.1 => 4.6.1 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: ^4.8.4 => 4.9.5

Please include below any other applicable logs and screenshots that show your problem:

✔ Pick your new app template › Full - includes DB and auth (Recommended)
✔ Install dependencies? › yarn
✔ Pick a form library (you can switch to something else later if you want) › Formik (Recommended)
Hang tight while we set up your new Blitz app!
CREATE    .env
CREATE    .env.local
CREATE    .env.test
CREATE    .eslintrc.js
CREATE    db/index.ts
CREATE    db/schema.prisma
CREATE    db/seeds.ts
CREATE    mailers/forgotPasswordMailer.ts
CREATE    next-env.d.ts
CREATE    next.config.js
CREATE    package.json
CREATE    public/favicon.ico
CREATE    public/logo.png
CREATE    src/auth/components/LoginForm.tsx
CREATE    src/auth/components/SignupForm.tsx
CREATE    src/auth/mutations/changePassword.ts
CREATE    src/auth/mutations/forgotPassword.test.ts
CREATE    src/auth/mutations/forgotPassword.ts
CREATE    src/auth/mutations/login.ts
CREATE    src/auth/mutations/logout.ts
CREATE    src/auth/mutations/resetPassword.test.ts
CREATE    src/auth/mutations/resetPassword.ts
CREATE    src/auth/mutations/signup.ts
CREATE    src/auth/schemas.ts
CREATE    src/blitz-client.ts
CREATE    src/blitz-server.ts
CREATE    src/core/components/Form.tsx
CREATE    src/core/components/LabeledTextField.tsx
CREATE    src/core/layouts/Layout.tsx
CREATE    src/pages/404.tsx
CREATE    src/pages/_app.tsx
CREATE    src/pages/_document.tsx
CREATE    src/pages/api/rpc/[[...blitz]].ts
CREATE    src/pages/auth/forgot-password.tsx
CREATE    src/pages/auth/login.tsx
CREATE    src/pages/auth/reset-password.tsx
CREATE    src/pages/auth/signup.tsx
CREATE    src/pages/index.tsx
CREATE    src/styles/Home.module.css
CREATE    src/styles/globals.css
CREATE    src/users/hooks/useCurrentUser.ts
CREATE    src/users/queries/getCurrentUser.ts
CREATE    test/index.test.tsx
CREATE    test/setup.ts
CREATE    test/utils.tsx
CREATE    tsconfig.json
CREATE    types.ts
CREATE    vitest.config.ts
IDENTICAL README.md

✔ Retrieving the freshest of dependencies
✔ Resolving packages
✔ Fetching packages
✔ Linking dependencies
✔ Building fresh packages
✔ Next.js was successfully patched with a React Suspense fix
✔ Routes manifest was successfully generated
✔ Committing your app

 Your new Blitz app is ready! Next steps:
   1. cd my-app
   2. blitz dev
@SilvanVerhoeven SilvanVerhoeven added kind/bug Something isn't working status/triage labels Oct 16, 2023
@siddhsuresh
Copy link
Member

siddhsuresh commented Oct 16, 2023

@SilvanVerhoeven thanks for the issue!

Sorry about that, next.js 13.5 has become a requirement for 2.0.0-beta.34 and has not been reflected on the template. I will update that now.

So for currently created apps please upgrade to latest next.js version (>13.5)

@SilvanVerhoeven
Copy link
Author

@siddhsuresh Awesome, works with latest nextjs (13.5.4)! Will you handle closing the issue?

@siddhsuresh
Copy link
Member

@SilvanVerhoeven great to hear 🎉 !

yeah, the issue will be auto closed once the PR is merged.

@tom-richter
Copy link

@siddhsuresh I'm getting the same error with version 2.0.0-beta.35, too.

For some reason blitz.js seems to pick still next version 13.4.5.

This is the package.json after running blitz new sample:

{
  "name": "sample",
  "version": "1.0.0",
  "scripts": {
    "dev": "blitz dev",
    "build": "blitz build",
    "start": "blitz start",
    "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
    "test": "vitest run --passWithNoTests",
    "test:watch": "vitest",
    "prepare": "husky install"
  },
  "prettier": {
    "semi": false,
    "printWidth": 100
  },
  "lint-staged": {
    "*.{js,ts,tsx}": [
      "eslint --fix"
    ]
  },
  "dependencies": {
    "@blitzjs/next": "2.0.0-beta.35",
    "blitz": "2.0.0-beta.35",
    "next": "13.4.5",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "ts-node": "10.9.1",
    "@blitzjs/rpc": "2.0.0-beta.35",
    "@blitzjs/auth": "2.0.0-beta.35"
  },
  "devDependencies": {
    "@next/bundle-analyzer": "12.0.8",
    "@testing-library/jest-dom": "5.16.3",
    "@types/node": "18.11.9",
    "@types/react": "18.0.25",
    "@typescript-eslint/eslint-plugin": "5.30.5",
    "@vitejs/plugin-react": "2.2.0",
    "eslint": "8.27.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-config-next": "12.3.1",
    "husky": "8.0.2",
    "jsdom": "20.0.3",
    "lint-staged": "13.0.3",
    "prettier": "^2.7.1",
    "pretty-quick": "3.1.3",
    "typescript": "^4.8.4",
    "vite-tsconfig-paths": "3.6.0",
    "vitest": "0.25.3"
  },
  "private": true
}
Blitz version: 2.0.0-beta.35 (global)
Blitz version: 2.0.0-beta.35 (local)
macOS Sonoma | darwin-arm64 | Node: v20.9.0


 Package manager: npm

  System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M1
    Memory: 782.39 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v20.9.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.35 => 2.0.0-beta.35 
    @blitzjs/next: 2.0.0-beta.35 => 2.0.0-beta.35 
    @blitzjs/rpc: 2.0.0-beta.35 => 2.0.0-beta.35 
    @prisma/client: Not Found
    blitz: 2.0.0-beta.35 => 2.0.0-beta.35 
    next: 13.4.5 => 13.4.5 
    prisma: Not Found
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: ^4.8.4 => 4.9.5 

@tom-richter
Copy link

@siddhsuresh
I think the problem is that you forgot to update the minimalapp package.ts.json

@lmisea
Copy link
Contributor

lmisea commented Dec 16, 2023

Hi @siddhsuresh, this problem is still present on the 2.0.0-beta.36, just like @tom-richter pointed.
The package.json after executing blitz new my-app is:

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "dev": "blitz dev",
    "build": "blitz build",
    "start": "blitz start",
    "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
    "test": "vitest run --passWithNoTests",
    "test:watch": "vitest",
    "prepare": "husky install"
  },
  "prettier": {
    "semi": false,
    "printWidth": 100
  },
  "lint-staged": {
    "*.{js,ts,tsx}": [
      "eslint --fix"
    ]
  },
  "dependencies": {
    "@blitzjs/next": "2.0.0-beta.36",
    "blitz": "2.0.0-beta.36",
    "next": "13.4.5",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "ts-node": "10.9.1",
    "@blitzjs/rpc": "2.0.0-beta.36",
    "@blitzjs/auth": "2.0.0-beta.36"
  },
  "devDependencies": {
    "@next/bundle-analyzer": "12.0.8",
    "@testing-library/jest-dom": "5.16.3",
    "@types/node": "18.11.9",
    "@types/react": "18.0.25",
    "@typescript-eslint/eslint-plugin": "5.30.5",
    "@vitejs/plugin-react": "2.2.0",
    "eslint": "8.27.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-config-next": "12.3.1",
    "husky": "8.0.2",
    "jsdom": "20.0.3",
    "lint-staged": "13.0.3",
    "prettier": "^2.7.1",
    "pretty-quick": "3.1.3",
    "typescript": "^4.8.4",
    "vite-tsconfig-paths": "3.6.0",
    "vitest": "0.25.3"
  },
  "private": true
}

Where the next dependency is still "next":"13.4.5". And not "next":"13.5.4".

@rene-demonsters
Copy link

@siddhsuresh I think the problem is that you forgot to update the minimalapp package.ts.json

Yep just ran into this exact issue, I opened a PR for it: #4405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/done
Projects
Status: Done
6 participants