vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.43k stars 26.79k forks source link

A bug preventing the app from running #54626

Closed H1Mohamed closed 3 months ago

H1Mohamed commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: ia32
      Version: Windows 10 Enterprise
    Binaries:
      Node: 18.17.1
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.19
      eslint-config-next: 13.4.19
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.2.2
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

CLI (create-next-app)

Link to the code that reproduces this issue or a replay of the bug

it is the littral starting template that is given when creating the app using the cli

To Reproduce

I ran the npx create-next-app@latest command

When I run npm run dev It started as usual but just stops working but says info Using wasm build of next-swc and then quits like this :

PS <file_path>> npm run dev

> my_app@0.1.0 dev
> next dev

- ready started server on [::]:3000, url: http://localhost:3000
- info Using wasm build of next-swc
PS <file_path>>

and when running npm start I get this error:

PS <file_path>> npm start

> my_app@0.1.0 start
> next start

- ready started server on [::]:3000, url: http://localhost:3000
[Error: ENOENT: no such file or directory, open 'F:\Programing-Coding\Web-Dev\amin_app\.next\BUILD_ID'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: '<file_path>\my_app\\.next\\BUILD_ID'
}

note that I'm using powershell and I replaced file names with <file_path> for personal resones

Describe the Bug

it's the app not working and the localhost not starting and giving error

Expected Behavior

well you all know what is supposed to happen and that is should be openning local host

Which browser are you using? (if relevant)

Microsoft Edge Version 116.0.1938.62 (Official build) (64-bit)

How are you deploying your application? (if relevant)

next start and next run dev

github-actions[bot] commented 1 year ago

We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.

Why was this issue marked with the please add a complete reproduction label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template for App Router, template for Pages Router), but you can also use these templates: CodeSandbox: App Router or CodeSandbox: Pages Router.

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

Please test your reproduction against the latest version of Next.js (next@canary) to make sure your issue has not already been fixed.

If you cannot create a clean reproduction, another way you can help the maintainers' job is to pinpoint the canary version of next that introduced the issue. Check out our releases, and try to find the first canary release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of next by running npm install next@<version>.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the please add a complete reproduction label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every Next.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

droslean commented 1 year ago

Same here.

williamhaley commented 1 year ago

I ran into a similar problem, though I was not using the starting template, so maybe the root cause is not the same. I'm working on a pet project and just starting to tinker with my Dockerfile configurations. I have a very basic setup and hit this error. This is a first draft and I'm sure there are obvious things wrong that don't need discussion here, but the BUILD_ID error struck me as pretty odd/confusing and that's how I found this issue

FROM node:20-bookworm-slim

WORKDIR /app

# Install dependencies based on the preferred package manager
COPY . .
RUN npm ci
RUN npm run build

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["npm", "run", "start"]
$ docker run --rm -it <my tag>

> <my-app>@0.1.0 start
> next start

- ready started server on [::]:3000, url: http://localhost:3000
[Error: ENOENT: no such file or directory, open '/app/.next/BUILD_ID'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/app/.next/BUILD_ID'
}

The issue seems fixed if I put an npm run build right after npm ci. Seems like build is required along with start.

FROM node:20-bookworm-slim

WORKDIR /app

# Install dependencies based on the preferred package manager
COPY . .
RUN npm ci
RUN npm run build

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["npm", "run", "start"]

From a distance, it feels weird that if I'm running a Next.js server for production that I also need to explicitly build first :shrug: I guess the docs do call out that a build is always required for prod along with npm run start:

next start starts the application in production mode. The application should be compiled with next build first...

...but it seems like something easy to overlook that the command to run in production always requires another command to be run first. Regardless, I then get a different error after adding in the npm run build.

- ready started server on [::]:3000, url: http://localhost:3000
Error: "next start" does not work with "output: export" configuration. Use "npx serve@latest out" instead.
    at /app/node_modules/next/dist/server/next.js:192:31
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NextServer.prepare (/app/node_modules/next/dist/server/next.js:153:24)
    at async Object.initialize (/app/node_modules/next/dist/server/lib/render-server.js:107:5) {
  type: 'Error'
}

This one's a little more self-explanatory. Error: "next start" does not work with "output: export" configuration. Use "npx serve@latest out" instead.. I had set output: 'export', in next.config.js while I was tinkering with different configurations. I removed that config setting since it's clear I can't really run an SPA for my needs. With that config dropped everything seems fine.

- ready started server on [::]:3000, url: http://localhost:3000

For the heck of it, with that config setting for output removed I also tried re-removing npm run build, but I hit the same issues as before.

dmythro commented 1 year ago

Same here, clean build for app with distDir: 'build' in a config generates this issue, even locally. There's no .next dir generated (checked with couple most recent patch versions) and it generates error like this: Error: ENOENT: no such file or directory, open '.../.next/BUILD_ID' via next start.

viictoorantonio commented 10 months ago

I was having exactly the same problem. I cleaned out the .next folder from my local repository and pushed an npx next build, now it created the files correctly so I can finally use npm start.

My file package.json

{
  "name": "project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "flowbite": "^1.8.1",
    "flowbite-react": "^0.6.3",
    "next": "^13.5.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@types/node": "latest",
    "@types/react": "latest",
    "@types/react-dom": "latest",
    "autoprefixer": "latest",
    "eslint": "latest",
    "eslint-config-next": "latest",
    "postcss": "latest",
    "tailwindcss": "latest",
    "typescript": "latest"
  }
}
balazsorban44 commented 3 months ago

This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

github-actions[bot] commented 3 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.