-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8.0.0 - dynamic import causing 'You may need an appropriate loader...' error #6240
Comments
I got same problem. Can't start develop mode. I updated npm to the latest version and also tried to install the acorn package, but did not help. |
I have a different error related to imports which might have the same root cause:
Everything is fine if I downgrade to [email protected] |
@AndrewIngram can you provide a reproduction? curious to look into that one. It sounds related to @babel/runtime, not webpack. |
I'm facing the same error. Installing |
For me this was fixed by upgrading @babel/core:
For some reason we have that as direct dependency currently. |
Experiencing same issue and error message. |
We are also seeing this issue and followed the threads for a workaround.
Following the the issues linked in the thread and installing (This also resolved the error about the Acorn package, which we do not have as a direct dependancy.) |
I had the same issue, also after updating |
Same issue here, unfortunately. Here's a replication: https://github.com/jescalan/nextjs-test/tree/je.canary Static build and export works wonderfully, it's just dev mode that errors. Neither babel nor webpack are installed as dependencies. |
Just fixed with with a removal of |
Removing |
Deleting |
Also experiencing this problem but outside of this package; Downgrading to a lower version of node (v9.11 [a colleagues working version], installing [email protected] and reinstalling node_modules fixed this for me. |
Facing the same issue as @AndrewIngram on a complex project. The issue only appears for |
I ran in to the same issue. Removing both |
I have the same behaviour in TypeScript files:
|
@icflorescu it's impossible to solve the issue without a clear reproduction. Please provide one so that we can investigate further 🙏 |
@icflorescu could you create a new issue for it (including reproduction) because it's not the same as this one 🙏 |
@timneutkens I finally discovered last night that my issue was caused by #6273. EDIT: I just published a test repo, see discussion in #6273. |
In my case, a simple complete re-install of the node_modules directory fixed this issue. It might related to the internal dependencies of the modules and the left over modules. |
I have the same issue (I also get the same error when using dynamic imports, I wrote about it on Spectrum https://spectrum.chat/users/matthew-rapati?thread=c677c233-8b02-447f-aff0-97b3399a493f). I tried removing node_modules, package-lock.json and clearing my npm cache, but it did not resolve the issue. If I have a chance I will try to create a small reproduction of the issue. |
Installing |
Installing acorn in Next.js doesn't solve the issue. |
Where I work, this has impacted us when trying to upgrade to next 8. |
Using Yarn to install dependencies did the trick for me. Super weird. |
Ok here is the winning combo (made sure is 100% reproducible):
Conclusion |
@vasco3 Big thanks! It works for me:
|
I used Yarn to install dependencies too and it works) |
thanks! proves once again that order matters! saved me. |
The current 8.1.1 canary track includes native TypeScript support, which includes official types for Next.js objects and out-of-the-box TypeScript compilation. This is good! But it means we have to adapt some of our existing TypeScript stuff. As of this writing, Next.js enforces that the app directory contain its own tsconfig.json file (vercel/next.js#7333), so this PR adds those as necessary, inheriting from the parent package’s configuration. It also requires a handful of specific configurations, so those are included as well (vercel/next.js#7361) in those files. This change also hoists acorn and acorn-dynamic-import because those two packages need to be in a consistent place relative to each other and webpack. (vercel/next.js#6240) Currently the 'next' module does not export a type for its constructor function, so we switch 'import next' to 'const next = require' to avoid the typechecking. We add "export {}" to the bottom of files that don’t do their own import / exporting to avoid an error due to the required "isolatedModules" setting. (These can be removed if "isolatedModules" is removed.) The bulk of the changes are updating _app and _document classes to the nice new types.
This fixed the issue for me too, thanks ! 👏 |
Thanks a ton, this fixed the problem. 👏👏 |
Will this be fixed in the canary branch any time soon? |
@TidyIQ we will be trying to fix it soon! It's important to note that this is a npm bug. |
@Timer webpack already fixed this problem see webpack/webpack#9370 |
This doesn't seem to fix the issue for me. Dealing with an older code base that can't quite upgrade to the new features yet, and i still need a transpiled server. I've done the above steps, and they don't solve the issue. I'm not even using dynamic imports :/
|
I may have solved this above problem by rm-ing node-modules and re-installing, but maybe not re-installing everything there might be a specific package which is causing this |
The final resolution steps should be to It's important to note that this is only fixed in Next 9. |
@Timer I'm running [email protected] and still having the issue. I've tried:
|
@Sm00g15 it's quite hard to help you when a reproduction is not provided. Maybe you installed webpack manually? |
Thanks, this solution solved the issue for me. I had been working on another Node.js project (not Next.js) where I'd upgraded my version of Node to the latest - this seems to be the cause of the issue. Where the solution to remove the lock.json and node_modules, then re-install the packages worked perfectly. Thanks. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Just upgraded to 8.0.0 and I'm really excited! I've run into an issue though that is preventing my project from compiling
Describe the bug
So when I run
dev
I am getting the following issueIt seems to be coming from
webpack 4.29.0
(see here).It looks like the issue was fixed with this which declared
acorn": "^6.0.5
as a dependency but the change doesn't seem to be present on masterMaybe I upgraded too soon?
The text was updated successfully, but these errors were encountered: