Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js cannot find module loader.js

This is the error is occurring when I try to run a npm run dev.

I don't understand what's happening and I tried these: deleting package-lock.json, deleting node_modules, reinstalling npm, but nothing works.

PS D:\Users\user\Documents\Projects\NLW#5\podcastrnext> npm run dev

> [email protected] dev D:\Users\user\Documents\Projects\NLW#5\podcastrnext
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: no next.config.js https://nextjs.org/docs/messages/webpack5
error - ../../NLW#5/podcastrnext/node_modules/next/dist/client/dev/amp-dev.js
Error: Cannot find module 'D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\@next\react-refresh-utils\loader.js'
Require stack:
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\compiled\webpack\bundle5.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\compiled\webpack\webpack.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\next-server\server\config-utils-worker.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\next-server\server\config-utils.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\next-server\server\config.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\server\next.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\server\lib\start-server.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\cli\next-dev.js
- D:\Users\user\Documents\Projects\NLW#5\podcastrnext\node_modules\next\dist\bin\next
<i> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.
<i> Until a full solution is available webpack uses an experimental ESM tracking based on parsing.
<i> As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking.
<i> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.
<i> Until a full solution is available webpack uses an experimental ESM tracking based on parsing.
<i> As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking.
like image 605
Victor Pessanha Avatar asked Apr 29 '21 20:04

Victor Pessanha


People also ask

Can not find module next?

Can not find module next? A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies. The module you're trying to import is in a different directory. The module you're trying to import has a different casing.

Can not find module node events?

The Error: Cannot find module 'node:events' occurs if you are not using the latest version of node. js 16.6. 0 or above and developing the discord bots. We can fix the issue by upgrading the Node.

What does module not found mean?

The 'module not found' error is a syntax error that appears when the static import statement cannot find the file at the declared path. This common syntax error is caused by letter-casing inconsistencies that are present in your filename(s) between your repository and local machine, or both.

How do I know my Nextjs version?

Or You can use Next. js CLI In your project root directory enter command npx next --version .


3 Answers

I had this same issue, removing the "#" from the project path worked just fine.

like image 110
Luis Oliveira Avatar answered Oct 15 '22 05:10

Luis Oliveira


I was able to resolve my problem, I don't know exactly what it was, but I might have a clue.

I was trying to run in this folder "D:\Users\user\Documents\Projects\NLW#5\podcastrnext" and didn't work. Than I tried changing to another folder, this is the folder that I used "D:\Users\user\Documents\Projects\podcastr" and this time worked.

I believe the problem was in the special character "#", somehow the program got lost with it.

like image 20
Victor Pessanha Avatar answered Oct 15 '22 07:10

Victor Pessanha


In file next.config.js insert in module.exports:

webpack5: false

like image 25
Thiago Menezes de Oliveira Avatar answered Oct 15 '22 06:10

Thiago Menezes de Oliveira