Error importing db from "db" when run blitz console #6
Open
Description
What is the problem?
blitz generator creates import line import db from "db"
When run blitz console
it can not find import from db.
Solution proposition:
The generator should be modified for creating valid db paths
Workaround:
Replace in the generated files the import strings import db from "db"
with:
- relative path, f.e.
import db from "../../../db"
(works for queries and mutations) - absolute root path
import db from /db/index.js
(works for mutations)
Paste all your error logs here:
Loaded env from /.env.local
Loaded env from /.env
You have entered the Blitz console
Tips: - Exit by typing .exit or pressing Ctrl-D
- Use your db like this: await db.project.findMany()
- Use your queries/mutations like this: await getProjects({})
00:07:07.229 ERROR Failed to load /app/auth/mutations/changePassword.js: Error: Cannot find module 'db'
Require stack:
- /app/auth/mutations/changePassword.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.238 ERROR Failed to load /app/auth/mutations/forgotPassword.js: Error: Cannot find module 'db'
Require stack:
- /app/auth/mutations/forgotPassword.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.247 ERROR Failed to load /app/auth/mutations/login.js: Error: Cannot find module 'db'
Require stack:
- /app/auth/mutations/login.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
Loading Modules 1/1700:07:07.262 ERROR Failed to load /app/auth/mutations/resetPassword.js: Error: Cannot find module 'db'
Require stack:
- /app/auth/mutations/resetPassword.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.272 ERROR Failed to load /app/auth/mutations/signup.js: Error: Cannot find module 'db'
Require stack:
- /app/auth/mutations/signup.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.281 ERROR Failed to load /app/tasks/mutations/createTask.js: Error: Cannot find module 'db'
Require stack:
- /app/tasks/mutations/createTask.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.293 ERROR Failed to load /app/tasks/mutations/deleteTask.js: Error: Cannot find module 'db'
Require stack:
- /app/tasks/mutations/deleteTask.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.302 ERROR Failed to load /app/tasks/mutations/updateTask.js: Error: Cannot find module 'db'
Require stack:
- /app/tasks/mutations/updateTask.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.311 ERROR Failed to load /app/tasks/queries/getTask.js: Error: Cannot find module 'db'
Require stack:
- /app/tasks/queries/getTask.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.320 ERROR Failed to load /app/tasks/queries/getTasks.js: Error: Cannot find module 'db'
Require stack:
- /app/tasks/queries/getTasks.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.329 ERROR Failed to load /app/users/mutations/updateUser.js: Error: Cannot find module 'db'
Require stack:
- /app/users/mutations/updateUser.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.337 ERROR Failed to load /app/users/queries/getCurrentUser.js: Error: Cannot find module 'db'
Require stack:
- /app/users/queries/getCurrentUser.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.346 ERROR Failed to load /app/user-profiles/mutations/createUserProfile.js: Error: Cannot find module 'db'
Require stack:
- /app/user-profiles/mutations/createUserProfile.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.354 ERROR Failed to load /app/user-profiles/mutations/updateUserProfile.js: Error: Cannot find module 'app/users/mutations/updateUser'
Require stack:
- /app/user-profiles/mutations/updateUserProfile.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
00:07:07.367 ERROR Failed to load /app/user-profiles/queries/getUserProfile.js: Error: Cannot find module 'db'
Require stack:
- /app/user-profiles/queries/getUserProfile.js
- /node_modules/next/dist/cli/next-console.js
- /node_modules/@blitzjs/cli/lib/src/commands/console.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/plugin.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/config.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/node_modules/@oclif/config/lib/index.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/command.js
- /node_modules/@blitzjs/cli/node_modules/@oclif/command/lib/index.js
- /node_modules/@blitzjs/cli/lib/src/index.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.dev.js
- /Users/sergous/.config/yarn/global/node_modules/blitz/cli/dist/blitz-cli.cjs.js
Loading Modules 2/17
⚡️ >
Paste all relevant code snippets here:
import db from "db";
What are detailed steps to reproduce this?
- blitz new (JS version)
- blitz console
Run blitz -v
and paste the output here:
Loaded env from /.env.local
Loaded env from /.env
macOS Big Sur | darwin-x64 | Node: v16.13.1
blitz: 0.45.3 (global)
blitz: 0.45.3 (local)
Package manager: yarn
System:
OS: macOS 11.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 3.50 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
Watchman: Not Found
npmPackages:
@prisma/client: 3.10.0 => 3.10.0
blitz: 0.45.3 => 0.45.3
prisma: 3.10.0 => 3.10.0
react: 18.0.0-beta-149b420f6-20211119 => 18.0.0-beta-149b420f6-20211119
react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
typescript: Not Found
Please include below any other applicable logs and screenshots that show your problem:
No response