Issues with some modules ?
See original GitHub issueDescribe the bug
When I import @ethersproject/bignumber
in a page I get the following error when loading the page :
500
Cannot read property 'BN' of undefined
TypeError: Cannot read property 'BN' of undefined
at ../src.ts/bignumber.ts:12:18
at instantiateModule (C:\dev\wighawag\test-svelte-kit\node_modules\vite\dist\node\chunks\dep-6e02b235.js:69027:166)
Logs
browser :
GET http://localhost:3000/ 500 (Internal Server Error)
cli:
[vite] Error when evaluating SSR module /node_modules/@ethersproject/bignumber/lib.esm/bignumber.js:
TypeError: Cannot read property 'BN' of undefined
at ../src.ts/bignumber.ts:12:18
at instantiateModule (C:\dev\wighawag\test-svelte-kit\node_modules\vite\dist\node\chunks\dep-6e02b235.js:69027:166) (x3)
To Reproduce
A repo created out of npm init svelte@next
here : https://github.com/wighawag/test-svelte-kit
yarn && yarn dev
Expected behavior can import es module
Severity This is a blocker as I rely on @ethersproject packages
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
On modules and separation of concerns - Loris Leiva
It forces you to stay predictable and design a better separation of concerns between modules as the application evolves.
Read more >Troubleshooting - Modules Anywhere - Regular Labs
Some slideshow modules or other fancy modules will not work properly when placed through Modules Anywhere. Some javascript based modules don't like to...
Read more >Your problems with Java modules : r/java - Reddit
The biggest issue with introducing modules into a codebase so far is estimating who needs what package exported or even open as we...
Read more >Problems with Python Modules - Stack Overflow
So for some reason I am having problems with modules. I have projects I made lets say 4 monthes ago that I downloaded...
Read more >Performance and consistency issues when modules or driver ...
Provides a workaround for the performance issue when certain modules are loaded into SQL Server address space or certain filter drivers are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s an FAQ with tips for the standard solutions to loading packages in Vite: https://kit.svelte.dev/faq#how-do-i-fix-the-error-i-m-getting-trying-to-include-a-package
I’m not sure whether this is the same issue though
This is a bug with Vite when bundling certain SSR dependencies and does not appear in a Vite template project because it does not perform SSR nor bundling.
You are correct that it should be in production dependencies, not dev dependencies, so that it can be bundled into the application. It looks like Vite is failing to see that
@ethersproject/bignumber
is referencingbn.js
.For a proper workaround that bundles the dependency into the application, do the following in
svelte.config.cjs
: