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
Deprecation - Invalid Main Field #509
Comments
I am having the same issue albeit with next.js app. Is this going to be a breaking issue? Any way to fix it or that I can help? (node:17672) [DEP0128] DeprecationWarning: Invalid 'main' field in 'C:\Users\ericm\websites2\capital\node_modules\react-icons\package.json' of 'lib'. |
@nolanleung Are there any plans to fix this issue as it's breaking all nextJS and gatsby builds? |
Same issue here however it's not breaking the build for me on Next. |
Let me see if I can reproduce... |
The problem is that node v16+ expects Hack Fix (may break the source)So instead of having the top package.json Top: {
"main": "lib",
"types": "./lib/esm/index.d.ts",
} Child (lib directory): {
"main": "./cjs/index.js",
"module": "./esm/index.js"
} Just point to Top: {
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"types": "lib/esm/index.d.ts",
} Proper FixWhile the above will fix the deprecation problem, there's still one more problem that ideally should be fixed in the next major release... ProblemBoth cjs/esm icon imports are pointing to Therefore removing lib's package.json will cause a bundler/compiler to throw an error because This predicament mainly has to do with the current folder structure, where cjs/esm files are mixed at the root-level parent directories, but separated within
SolutionInstead, separate all cjs and esm files within
With above folder structure, icon imports would then change to...
...and point to their respective parent directories. The package.json would then be: {
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"types": "lib/index.d.ts",
} Other thoughtsThe above is heavily opinionated and can be changed to many other folder structures/file types approaches. For example, cjs could be root-level within lib but esm is separated; as well as, esm could use the |
Getting the same issue on a Next build (not breaking the build however). Error message is as follows:
|
Today the problem persist on nextjs |
Today the problem persist on Vite |
I'm also getting this warning on my next.js app. |
yes, and today... i'm using "react-icons": "^4.4.0", and get the same error
|
Hello all, Im also getting this error. I am using When a deployment is triggered i get the following warning: (node:391) [DEP0128] DeprecationWarning: Invalid 'main' field in '/vercel/path0/node_modules/react-icons/package.json' of 'lib'. Please either fix that or report it to the module author
--
12:37:58.377 | (Use `node --trace-deprecation ...` to show where the warning was created)
12:38:01.445 | 05:38:01 PM [build] Completed in 3.24s.
12:38:01.445 | 05:38:01 PM [build] Building entrypoints for prerendering...
12:38:02.764 | 05:38:02 PM [build] Completed in 1.32s.
12:38:02.764 | followed by this error which causes the build to fail: 12:38:05.145 | generating static routes
12:38:05.275 | error Directory import '/vercel/path0/node_modules/react-icons/vsc' is not supported resolving ES modules imported from /vercel/path0/dist/entry.mjs
12:38:05.275 | Did you mean to import react-icons/vsc/index.js?
12:38:05.275 | at new NodeError (node:internal/errors:372:5)
12:38:05.275 | at finalizeResolution (node:internal/modules/esm/resolve:433:17)
12:38:05.275 | at moduleResolve (node:internal/modules/esm/resolve:1009:10)
12:38:05.275 | at defaultResolve (node:internal/modules/esm/resolve:1218:11)
12:38:05.275 | at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
12:38:05.275 | at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
12:38:05.276 | at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
12:38:05.276 | at link (node:internal/modules/esm/module_job:78:36)
12:38:05.424 | Error: Command "npm run build" exited with 1 |
Here the same error wit Astro and react
A straightforward solution or a fix would be super nice. This problem has existed for almost a year. |
Same problem as others, with a NextJs project.
|
The problem still persists in NextJS:
|
Still persists in NextJS, a year after initially reported. Luckily it doesn't seem to be breaking.
|
Fresh install still shows the {
"name": "react-icons",
"version": "4.7.1",
"description": "SVG React icons of popular icon packs using ES6 imports",
"author": "Goran Gajic",
"contributors": [
"kamijin_fanta <kamijin@live.jp>"
],
"license": "MIT",
"main": "lib",
"types": "./lib/esm/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:react-icons/react-icons.git"
},
...
} That means that the distributed package.json is in fact not fixed. |
@kamijin-fanta can you please take a look? So frustrating, we can't use it with NextJS and AstroJS |
Across multiple frameworks, users receive a `[DEP0128] DeprecationWarning: Invalid 'main' field in ...` warning. Removing this line fixes it. Issue: react-icons#509
I pre-released a version react-icons@4.8.1-snapshot.0 (or react-icons@beta) containing this commit. Try it out on your project and give us your feedback. thank you. |
Good evening, just to let you know, I've installed the version you're suggesting as a potential solution and it still does not work. here is the error message my NEXT.js app is giving: |
The problem is unfortunately not fixed yet. |
thank you. Validate in a Next.js project. |
Fixed an issue where packages were not built correctly. Try react-icons@4.8.1-snapshot.1. My Next.js project builds without any warnings. |
Awesome. With |
Awesome, this worked for me as well in Vite (ReactJS). Thanks. |
4.8.1-snapshot.1 also works for me in a new astro project. |
Using 4.8.1-snapshot.1 and building with Vite@4.1.4, I get the following error if I import using
It works if I import using |
@gxxcastillo Thanks for your feedback! I built vite@4.1.4, nodejs 18.15.0, react-icons@4.8.1-snapshot.1 and it completed successfully. It looks like a problem with build settings such as Vite. |
@kamijin-fanta i am getting the same error, i used vite for bundling |
Awesome. I am using Astro with React. I got the same error with version 4.8.0. Uninstalled that, and installed this package. NO WARNING NOW 😍😍😍. Many thanks. |
solved my issue buliding w/ vite for an SSR project. Thanks! |
Describe the problems
I use React Icons with Gatsby. Here is the error I received on load:
(node:46591) [DEP0128] DeprecationWarning: Invalid 'main' field in
'/Users/jvkrakowski/Desktop/dev/gatsby/nine-realms/node_modules/react-icons/package.json' of 'lib'. Please
either fix that or report it to the module author
(Use
node --trace-deprecation ...
to show where the warning was created)Expected behavior
The error appears once you issue the "gatsby develop" command on terminal.
Desktop (please complete the following information):
Additional context
I updated to Gatsby version 4, and I'm using NPM version 8
The text was updated successfully, but these errors were encountered: