Next.js Discord

Discord Forum

Cannot run `npm run dev` on fresh install, if under certain directories

Unanswered
ramana posted this in #help-forum
Open in Discord
I did a completely fresh app with npx create-next-app@latest and tried to run it and run into this error:

Error: Cannot find module 'next/dist/compiled/semver'

I am having a lot of trouble trying to debug this. Can someone help?

21 Replies

$ npm --version
10.8.3
$ node --version
v22.9.0
$ cat package.json
{
  "name": "testfresh",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "react": "^18",
    "react-dom": "^18",
    "next": "14.2.13"
  },
  "devDependencies": {
    "typescript": "^5",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "eslint": "^8",
    "eslint-config-next": "14.2.13"
  }
}
$ npm run dev

> testfresh@0.1.0 dev
> next dev

  ▲ Next.js 14.2.13
  - Local:        http://localhost:3000

 ✓ Starting...
Error: Cannot find module 'next/dist/compiled/semver'
Require stack:
- /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js
- /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/lib/verify-typescript-setup.js
- /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js
- /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/router-server.js
- /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/start-server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at /home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/require-hook.js:55:36
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at mod.require (/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js:26:56)
    at Module._compile (node:internal/modules/cjs/loader:1546:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js',
    '/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/lib/verify-typescript-setup.js',
    '/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js',
    '/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/router-server.js',
    '/home/ramana/vrün/fresh/testfresh/node_modules/next/dist/server/lib/start-server.js'
  ]
}
$ npm list -g
/home/ramana/.local/lib
├── @html-to/text-cli@0.5.4
├── browserify@17.0.0
└── http-server@14.1.1
I'm pretty sure nextjs or one of its dependencies has a bug here, but I can't find anyone else reporting it.
@gin on what system are u?
$ uname -a
Linux mia 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 x86_64 GNU/Linux
@gin weird
can you reproduce on these versions?
@ramana can you reproduce on these versions?
works fine for me ngl
can u try clearing ur npm cache
if possible?
yes, I have tried that npm cache clean --force -- did not help
@gin works fine for me ngl
same versions?
yup
strange
i'm gonna try it again right now in a fresh directory, i will document everything i do
alr
OK wow - I got it to work! By doing it in a totally different subdirectory. But then when I move that into the original directory I was using, it fails
can I ask you to try it in a directory named vrün like I had?
I wonder if there's a bug in handling the directory name?
(I can confirm it works if I move it to a different directory again)