blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js

Home Page:https://Blitzjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ajv dependency was not installed with blitz new

openspaceranger opened this issue · comments

What is the problem?

There is a missing dependency called ajv that will result in the app erroring out on the first run. It gets resolved once we install ajv.

Paste all your error logs here:

PS C:\Workspace\blitz-blank> npm run dev

> blitz-blank@1.0.0 dev
> blitz dev

Loaded env from C:\Workspace\blitz-blank\.env.local
Loaded env from C:\Workspace\blitz-blank\.env
✔ Next.js was successfully patched with a React Suspense fix
✔ Routes manifest was successfully generated
  ▲ Next.js 13.5.4
  - Local:        http://localhost:3000
  - Environments: .env.local, .env
  - Experiments (use at your own risk):
     · typedRoutes

 ✓ Ready in 3.9s
 ○ Compiling /page ...
 ⨯ ./node_modules/ajv-keywords/dist/definitions/_util.js:4:0
Module not found: Can't resolve 'ajv/dist/compile/codegen'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/ajv-keywords/dist/definitions/regexp.js
./node_modules/ajv-keywords/dist/keywords/regexp.js
./node_modules/ajv-keywords/dist/keywords/index.js
./node_modules/ajv-keywords/dist/index.js
./node_modules/schema-utils/dist/validate.js
./node_modules/schema-utils/dist/index.js
./node_modules/copy-webpack-plugin/dist/index.js
./node_modules/@blitzjs/next/dist/index-server.cjs
./src/app/blitz-client.ts

Paste all relevant code snippets here:

There is no new code. This is a newly generated app with nothing in it aside from defaults.

What are detailed steps to reproduce this?

1.blitz new your-app
2.npm run dev
3.open localhost:3000

Run blitz -v and paste the output here:

Blitz version: 2.0.2 (global)
Blitz version: 2.0.3 (local)
Windows 10 | win32-x64 | Node: v20.10.0


 Package manager: npm

  System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
    Memory: 14.87 GB / 31.78 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.0.2 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @blitzjs/auth: 2.0.3 => 2.0.3
    @blitzjs/next: 2.0.3 => 2.0.3
    @blitzjs/rpc: 2.0.3 => 2.0.3
    @prisma/client: 5.4.2 => 5.4.2
    blitz: 2.0.3 => 2.0.3
    next: 13.5.4 => 13.5.4
    prisma: 5.4.2 => 5.4.2
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: 4.8.4 => 4.8.4

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

blitz ajv 2024-01-16 224021

Same issue here. Not a good look when this is the first thing I get when attempting to investigate blitz verses refine.dev.

I find the idea behind this project great. BlitzRPC seems easier to set up and work with than tRPC.

However, it seems like the CLI itself has fallen a bit behind (eg. Not fully supporting App Router within recipes or code generation actions).
That renders it not yet ready for production use out of the box in my opinion.

That being said, I fixed this error by running:

npm install --save-dev ajv@^7 

(Source: https://stackoverflow.com/questions/70020046/quasar-error-cannot-find-module-ajv-dist-compile-codegen)

I find the idea behind this project great. BlitzRPC seems easier to set up and work with than tRPC.

However, it seems like the CLI itself has fallen a bit behind (eg. Not fully supporting App Router within recipes or code generation actions). That renders it not yet ready for production use out of the box in my opinion.

That being said, I fixed this error by running:

npm install --save-dev ajv@^7 

(Source: https://stackoverflow.com/questions/70020046/quasar-error-cannot-find-module-ajv-dist-compile-codegen)

This worked for me as well, should be easily fixed though, should work out of the box when first running it, especially when the bug is so tiny

A workaround: #4294 (comment)

Hey, a PR to fix this is welcome.