langtrace icon indicating copy to clipboard operation
langtrace copied to clipboard

NextJS Error: Couldn't find any `pages` or `app` directory

Open amarion35 opened this issue 1 year ago • 6 comments

I'm installing the self-hosted version with kubernetes but I got the following logs in the langtrace-app pod:

The _prisma_migrations table does not exist. Proceeding to start the app.
> [email protected] predev
> npm run run-migrations && npm run create-clickhouse-db
> [email protected] run-migrations
> npx prisma migrate deploy
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "langtrace", schema "public" at "langtrace-postgres:5432"
2 migrations found in prisma/migrations
Applying migration `0_init`
Applying migration `20240804000535_modify_data_columns_expectedoutput_model`
The following migration(s) have been applied:
migrations/
  └─ 0_init/
    └─ migration.sql
  └─ 20240804000535_modify_data_columns_expectedoutput_model/
    └─ migration.sql
      
All migrations have been successfully applied.
> [email protected] create-clickhouse-db
> npx tsx scripts/create-clickhouse-db.ts
Creating Clickhouse DB if not exists...
5b4dca07-bb2a-441a-9062-ce724eee009b
> [email protected] dev
> next dev
  ▲ Next.js 14.2.5
  - Local:        http://localhost:3000
 ✓ Starting...
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root
    at findPagesDir (/app/node_modules/next/dist/lib/find-pages-dir.js:42:15)
    at initialize (/app/node_modules/next/dist/server/lib/router-server.js:75:69)
    at async Server.<anonymous> (/app/node_modules/next/dist/server/lib/start-server.js:249:36)
?25h
npm notice 
npm notice New minor version of npm available! 10.2.4 -> 10.8.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.2>;
npm notice Run `npm install -g [email protected]` to update!
npm notice 

It looks like the app directory is missing. And indeed, according to the Dockerfile, the app directory is copied in the builder intermediate image but not copied from the builder to the production image.

amarion35 avatar Aug 26 '24 15:08 amarion35

Hi @amarion35 , thanks for reporting this. We will take a look and get back to you.

karthikscale3 avatar Aug 26 '24 15:08 karthikscale3

Hey @amarion35 , looks like you are running the client in dev mode.

  • could you make sure that NEXT_PUBLIC_ENVIRONMENT is set to production? If not already?
  • Or maybe you are mounting a local volume?

darshit-s3 avatar Aug 26 '24 17:08 darshit-s3

To install langtrace I tried this guide: https://docs.langtrace.ai/hosting/hosting_options/kubernetes So the environment variables were the default ones except the AZURE ones.

Since it wasn't working, I tried to clone the repo, at the following tag 3.0.0. Then I added this line to the Dockerfile COPY --from=builder /app/app ./app, I built the image and it worked. The install worked and the pods seems to be running correctly but the app URL was unreachable. In the end I tried the docker compose option and it worked on the first try.

amarion35 avatar Aug 27 '24 09:08 amarion35

Hey @amarion35 , We have updated the helm chart with the default value of environment variable NEXT_PUBLIC_ENVIRONMENT set to production you should now not face this issue.

Give it a try and let us know. Thanks again for reporting.

The following are some helpful commands to re-install Langtrace helm if needed
helm repo remove langtrace
helm repo add langtrace https://Scale3-Labs.github.io/langtrace-helm-chart
helm install langtrace langtrace/langtrace

darshit-s3 avatar Aug 28 '24 03:08 darshit-s3

Hey @amarion35 , We have updated the helm chart with the default value of environment variable NEXT_PUBLIC_ENVIRONMENT set to production you should now not face this issue.

Give it a try and let us know. Thanks again for reporting. The following are some helpful commands to re-install Langtrace helm if needed

With the new helm chart i still run into an issue. I described it here

a-klos avatar Sep 05 '24 14:09 a-klos

Hey @FeU-aKlos , thanks for reporting the issue. This as been fixed in the latest 3.0.4 release. You may pull the latest image and try again.

darshit-s3 avatar Sep 09 '24 13:09 darshit-s3

Closing this issue as it has been inactive. Please reopen if you see any this issue again.

karthikscale3 avatar Oct 13 '24 17:10 karthikscale3