Error on starting up the dev-server in my next js app

Viewed 1045

When I try to start the dev server of my nextjs website I get the following output:

> social-media-website@0.1.0 dev C:\Users\parth\Desktop\projects\social-media-website- 
git\social-media-app
> next dev

internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'C:\Users\parth\Desktop\projects\social-media-website-git\social-media-app\node_modules\next\dist\bin\next'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! social-media-website@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the social-media-website@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\parth\AppData\Roaming\npm-cache\_logs\2020-07-21T07_35_10_437Z-debug.log

The result was same in case of yarn and npm. Here's my debug log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v14.3.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle social-media-website@0.1.0~predev: social-media-website@0.1.0
6 info lifecycle social-media-website@0.1.0~dev: social-media-website@0.1.0
7 verbose lifecycle social-media-website@0.1.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle social-media-website@0.1.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\parth\Desktop\projects\social-media-website-git\social-media-app\node_modules\.bin;C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Users\parth\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\parth\AppData\Roaming\npm;C:\Users\parth\AppData\Local\Yarn\bin
9 verbose lifecycle social-media-website@0.1.0~dev: CWD: C:\Users\parth\Desktop\projects\social-media-website-git\social-media-app
10 silly lifecycle social-media-website@0.1.0~dev: Args: [ '/d /s /c', 'next dev' ]
11 silly lifecycle social-media-website@0.1.0~dev: Returned: code: 1  signal: null
12 info lifecycle social-media-website@0.1.0~dev: Failed to exec dev script
13 verbose stack Error: social-media-website@0.1.0 dev: `next dev`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1051:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid social-media-website@0.1.0
15 verbose cwd C:\Users\parth\Desktop\projects\social-media-website-git\social-media-app
16 verbose Windows_NT 10.0.19041
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v14.3.0
19 verbose npm  v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error social-media-website@0.1.0 dev: `next dev`
22 error Exit status 1
23 error Failed at the social-media-website@0.1.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I tried reinstalling my dependencies and it worked for the first time but the result was same when I tried again.
Edit: I noticed that it worked every time I reinstalled dependencies but that's not one would want!
Please help if you know a way of fixing this. Thank You!

0 Answers
Related