Search code examples
reactjsnpmnpm-start

Trying to build my first React app locally and npm start wont work


So when I try to run npm start this is the error

[Error: ENOENT: no such file or directory, open 'C:\Users\Elijah\vscode\React project\react-project\.next\BUILD_ID'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\Elijah\\vscode\\React project\\react-project\\.next\\BUILD_ID'
}

Pretty sure I got my path correct which is C:\Users\Elijah\vscode\React project\react-project>

and my package.json is

{
  "name": "react-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "eslint": "8.48.0",
    "eslint-config-next": "13.4.19",
    "next": "13.4.19",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  }
}

I've done a clean installation checked if they were downloaded correctly and I've also tried deleting package-lock.json and node_modules and running npm install and still nothing. Also tried installing webpack


Solution

  • I have also faced the issue. Try this first:

    npm run dev
    

    If the above command didn't helped then try:

    npm run build
    

    It should create a .next directory. Then you can run npm start later on. I don't know why this issue exists.