t3-oss / create-t3-turbo

Clean and simple starter repo using the T3 Stack along with Expo React Native
https://turbo.t3.gg
MIT License
4.73k stars 408 forks source link

bug: Can't find local modules in fresh setup. #1129

Closed BlackBeardo closed 3 months ago

BlackBeardo commented 4 months ago

Provide environment information

    OS: Windows 11 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 5.34 GB / 15.89 GB
  Binaries:
    Node: 20.15.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.5.0 - ~\AppData\Local\pnpm\pnpm.EXE```

### Describe the bug

1. I grab code using ``npx create-turbo@latest -e https://github.com/t3-oss/create-t3-turbo``. 
2. copied ``.env.example`` into ``.env``, changed pg link with real one.
3. ``pnpm install``. done.
4. ``pnpm db:push``. done. 
5.  but when I open my editor and just looking through files and found TS Errors on multiple pages: 
like... ``packages/auth/src/config.ts``, saying that ``Cannot find module '@acme/db/client' or its corresponding type declarations.`` and ``Cannot find module '@acme/db/schema' or its corresponding type declarations.`` for imports.

I did restart editor as well as tried restart ts server and eslint server. but not errors not going away.

I thought may be i need to run ``pnpm run dev``. for first time to create types and all, but when i ``pnpm dev``,
got errors:

```pnpm dev

> create-t3-turbo@ dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1
> turbo watch dev

╭──────────────────────────────────────────────────────────────────────╮
│                                                                      │
│                   Update available v2.0.8 ≫ v2.0.9                   │
│    Changelog: https://github.com/vercel/turbo/releases/tag/v2.0.9    │
│           Run "npx @turbo/codemod@latest update" to update           │
│                                                                      │
│        Follow @turborepo for updates: https://x.com/turborepo        │
╰──────────────────────────────────────────────────────────────────────╯
 WARNING  stale pid file at "C:\\Users\\KKR\\AppData\\Local\\Temp\\turbod\\f0d016d61cf905e5\\turbod.pid"
• Packages in scope: @acme/api, @acme/auth, @acme/auth-proxy, @acme/db, @acme/eslint-config, @acme/expo, @acme/github, @acme/nextjs, @acme/prettier-config, @acme/tailwind-config, @acme/tsconfig, @acme/ui, @acme/validators
• Running dev in 13 packages
• Remote caching disabled
┌ @acme/validators#dev > cache bypass, force executing 782b224cb9d9b149
│
│ > @acme/validators@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\packages\validators
│ > tsc
└────>
┌ @acme/db#dev > cache bypass, force executing e8177f459864e042
│
│ > @acme/db@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\packages\db
│ > tsc
└────>
┌ @acme/nextjs#dev > cache bypass, force executing 4442dada2215f5ed
│
│ > @acme/nextjs@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\apps\nextjs
│ > pnpm with-env next dev
│
│
│ > @acme/nextjs@0.1.0 with-env C:\Users\KKR\Desktop\myAppName-t3-oss\v1\apps\nextjs
│ > dotenv -e ../../.env -- "next" "dev"
│
│   ▲ Next.js 14.2.4
│   - Local:        http://localhost:3000
│
│  ✓ Starting...
└────>
┌ @acme/ui#dev > cache bypass, force executing 2161149152def477
│
│ > @acme/ui@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\packages\ui
│ > tsc
└────>
┌ @acme/expo#dev > cache bypass, force executing 8758b0bff027807a
│
│ > @acme/expo@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\apps\expo
│ > expo start
│
│ Starting project at C:\Users\KKR\Desktop\myAppName-t3-oss\v1\apps\expo
│ Using src/app as the root directory for Expo Router.
│ Starting Metro Bundler
└────>
┌ @acme/api#dev > cache bypass, force executing 25e8ecbdf0d11b4a
│
│ > @acme/api@0.1.0 dev C:\Users\KKR\Desktop\myAppName-t3-oss\v1\packages\api
│ > tsc
│
│ src/router/post.ts:4:26 - error TS2307: Cannot find module '@acme/db' or its corresponding type declarations.
│
│ 4 import { desc, eq } from "@acme/db";
│                            ~~~~~~~~~~
│
│ src/router/post.ts:5:40 - error TS2307: Cannot find module '@acme/db/schema' or its corresponding type declarations.
│
│ 5 import { CreatePostSchema, Post } from "@acme/db/schema";
│                                          ~~~~~~~~~~~~~~~~~
│
│ src/trpc.ts:15:20 - error TS2307: Cannot find module '@acme/db/client' or its corresponding type declarations.
│
│ 15 import { db } from "@acme/db/client";
│                       ~~~~~~~~~~~~~~~~~
│
│ ../auth/src/config.ts:10:20 - error TS2307: Cannot find module '@acme/db/client' or its corresponding type declarations.
│
│ 10 import { db } from "@acme/db/client";
│                       ~~~~~~~~~~~~~~~~~
│
│ ../auth/src/config.ts:11:40 - error TS2307: Cannot find module '@acme/db/schema' or its corresponding type declarations.
│
│ 11 import { Account, Session, User } from "@acme/db/schema";
│                                           ~~~~~~~~~~~~~~~~~
│
│
│ Found 5 errors in 3 files.
│
│ Errors  Files
│      2  src/router/post.ts:4
│      1  src/trpc.ts:15
│      2  ../auth/src/config.ts:10
│  ELIFECYCLE  Command failed with exit code 2.
│ command finished with error: command (C:\Users\KKR\Desktop\myAppName-t3-oss\v1\packages\api) C:\Users\KKR\AppData\Local\pnpm\pnpm.exe run dev exited (2)
└────>
  × internal errors encountered: unable to determine why task exited

Link to reproduction

https://github.com/t3-oss/create-t3-turbo

To reproduce

I did not change any part. not a single word. I did changed env vars, which works perfectly because I did pnpm db:push and worked. i confirmed with my supabase dashboard. all tables created. so I have no idea what to fix.

Additional information

No response

BlackBeardo commented 4 months ago

for visual ref: Untitled

w4jo commented 4 months ago

Did u try: pnpm run build in root?

BlackBeardo commented 3 months ago

Did u try: pnpm run build in root?


pwsh> pnpm build

> create-t3-turbo@ build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1
> turbo run build

╭──────────────────────────────────────────────────────────────────────╮
│                                                                      │
│                   Update available v2.0.8 ≫ v2.0.9                   │
│    Changelog: https://github.com/vercel/turbo/releases/tag/v2.0.9    │
│           Run "npx @turbo/codemod@latest update" to update           │
│                                                                      │
│        Follow @turborepo for updates: https://x.com/turborepo        │
╰──────────────────────────────────────────────────────────────────────╯
• Packages in scope: @acme/api, @acme/auth, @acme/auth-proxy, @acme/db, @acme/eslint-config, @acme/expo, @acme/github, @acme/nextjs, @acme/prettier-config, @acme/tailwind-config, @acme/tsconfig, @acme/ui, @acme/validators
• Running build in 13 packages
• Remote caching disabled
┌ @acme/db#build > cache hit (outputs already on disk), replaying logs 459277a26a34a2db
│
│ > @acme/db@0.1.0 build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\packages\db
│ > tsc
└────>
┌ @acme/ui#build > cache hit (outputs already on disk), replaying logs 00fec255097d554b
│
│ > @acme/ui@0.1.0 build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\packages\ui
│ > tsc
└────>
┌ @acme/validators#build > cache hit, replaying logs d65186b9438feae2
│
│ > @acme/validators@0.1.0 build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\packages\validators
│ > tsc
└────>
┌ @acme/api#build > cache hit, replaying logs c79197e431b63d2a
│
│ > @acme/api@0.1.0 build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\packages\api
│ > tsc
└────>
┌ @acme/auth-proxy#build > cache miss, executing 854adffeec4fb7d8
│ 
│ > @acme/auth-proxy@ build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\apps\auth-proxy
│ > nitro build
│
│ ✔ Generated public .output/public                                                                                                                                                                                                                                                        n
│ itro 12:25:16 pm
│ ℹ Building Nitro Server (preset: node-server)                                                                                                                                                                                                                                            n
│ itro 12:25:16 pm
│ ../../node_modules/@auth/core/lib/utils/cookie.js (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
│ ../../node_modules/@auth/core/lib/utils/cookie.js (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
│ ../../node_modules/@auth/core/lib/utils/cookie.js (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
│ ../../node_modules/@auth/core/lib/utils/cookie.js (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
│ ^C ELIFECYCLE  Command failed with exit code 3221225786.
└────>
┌ @acme/nextjs#build > cache miss, executing c6ad9ab5c0759d25
│
│ > @acme/nextjs@0.1.0 build C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\apps\nextjs
│ > pnpm with-env next build
│
│
│ > @acme/nextjs@0.1.0 with-env C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\apps\nextjs
│ > dotenv -e ../../.env -- "next" "build"
│
│   ▲ Next.js 14.2.4
│
│    Creating an optimized production build ...
│ Failed to compile.
│
│ ./src/app/api/trpc/[trpc]/route.ts
│ Module not found: Can't resolve '@acme/api'
│
│ https://nextjs.org/docs/messages/module-not-found
│
│ ./src/trpc/server.ts
│ Module not found: Can't resolve '@acme/api'
│
│ https://nextjs.org/docs/messages/module-not-found
│
│ Import trace for requested module:
│ ./src/app/page.tsx
│
│
│ > Build failed because of webpack errors
│  ELIFECYCLE  Command failed with exit code 1.
│  ELIFECYCLE  Command failed with exit code 1.
│ command finished with error: command (C:\Users\patel\OneDrive\Desktop\t3-next\mono\v1\apps\nextjs) C:\Users\patel\AppData\Roaming\npm\pnpm.cmd run build exited (1)
└────>
  × internal errors encountered: unable to determine why task exited

 ELIFECYCLE  Command failed with exit code 1.```
w4jo commented 3 months ago

To fix this, you can try clearing your cache, removing all your projects, deleting the pnpm~.lock file, and then installing the dependencies again.

Also, it seems like a new version of @auth/core and next-auth is being installed, along with the drizzle adapter. I know that installing a new version can sometimes cause issues.

These packages are still in beta, so be aware of that.

If you’re getting new versions, you can remove the ^ from the package version to get exactly that version, if you want to wait for the PR to fix the code.

trevorpfiz commented 3 months ago

To fix this, you can try clearing your cache, removing all your projects, deleting the pnpm~.lock file, and then installing the dependencies again.

Also, it seems like a new version of @auth/core and next-auth is being installed, along with the drizzle adapter. I know that installing a new version can sometimes cause issues.

These packages are still in beta, so be aware of that.

If you’re getting new versions, you can remove the ^ from the package version to get exactly that version, if you want to wait for the PR to fix the code.

thanks. I ran pnpm clean:workspaces, pnpm store prune, rm -rf .turbo, reinstalled with pnpm i and then pnpm build and things worked.