next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Cannot find module './components.cjs.development.js'

Open The-Code-Monkey opened this issue 1 year ago • 7 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 Binaries: Node: 16.15.0 npm: 8.5.5 Yarn: 1.22.15 pnpm: 6.11.0 Relevant packages: next: 13.0.1-canary.0 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Im using my own component lib and its working on the homepage but when you go to the list/products page it throw the error.

Cannot find module './components.cjs.development.js' What is strange is that the file in question is installed as i used it on another page just fine, and then there is no direct link to that file it gets called via the index.js file in the node_modules. which confirms that it is reading the correct filesystem.

Expected Behavior

It should load the file like it does on the previous page.

Link to reproduction

https://github.com/The-Code-Monkey/PaperCMS

To Reproduce

Go to the linked repo and you should be able to see the failed deploy. Its really strange, you might have to load it locally as it runs on dev unless you click the products link, all elements are built using the Box component which is what is failing on the other page. Not sure why.

The-Code-Monkey avatar Oct 27 '22 11:10 The-Code-Monkey

There is a box component used on every page, whether thats the layout, page or a component, but for some reason only the nested pages break.

The-Code-Monkey avatar Oct 27 '22 11:10 The-Code-Monkey

Is there a way to global set use client on all layouts and pages as that i have found fixes everything. probably due to the use of context inside my Component lib.

The-Code-Monkey avatar Oct 28 '22 10:10 The-Code-Monkey

I have the same issue for the past week... issue got automatically closed my maintainer... which is very sad.

Some of the module errors involve .cjs as well as other files that are not even in my project like the most recent error: Error: Cannot find module './952.js'

https://github.com/vercel/next.js/issues/41996

This is affecting both dev and prod.

On dev, it happens right after I push changes and try to refresh page. it gives 404 page.

On prod through analytics it shows users are getting 404 page sometime.

temrb avatar Oct 30 '22 17:10 temrb

also mentioned here:

https://github.com/vercel/next.js/issues/36320

I am not using babel, I get same errors with SWC..

temrb avatar Oct 30 '22 17:10 temrb

I'm glad I'm not the only one who has this issue, the strange one for me though is I've also ran it in es module mode and it still picks up the .cjs version even though I have a compiled esm version. What I can't get my head around is that it works on the route URL but then when you go to a sub URL it crashes. It's actually stopping my build from being successful

The-Code-Monkey avatar Oct 30 '22 19:10 The-Code-Monkey

also relating to the docs:

https://nextjs.org/docs/messages/module-not-found

I am not using any of the getstatic methods .

This doesnt correlate to any modules that I am importing in my app or it would say it in the call stack

Rather it saying random file names that I dont have in my app..

//node_modules/next/dist/server/require.js

It relates to next/dist/server/require @ https://github.com/vercel/next.js/issues/41996

Rather it relates to the module nextjs is using... hoping for a fix for this soon as it is affecting my applications.

temrb avatar Oct 30 '22 20:10 temrb

@The-Code-Monkey What I think fixed it for me... was creating a new repo and moving all my contents from my old repo and doing a clean module install. I believe it is a caching issue with nextjs.

When I do run dev after pushing / commiting to dev that error doesnt pop up.

temrb avatar Oct 31 '22 02:10 temrb

This one fixed for me due to having the components use context so it was crashing. i just had to add use client to all the pages that had a component on.

The-Code-Monkey avatar Nov 03 '22 10:11 The-Code-Monkey