Closed JoePotentier closed 1 year ago
I added the exports
field to the package.json in v10.4.0 published 5 days ago, which means that only the paths explicitly exported can now be imported.
Unfortunately, I do not know much about Nestjs/typescript or why your project is trying to use a non-existent subpath './decimal'.
"main": "decimal",
"module": "decimal.mjs",
"browser": "decimal.js",
"exports": {
".": {
"types": "./decimal.d.ts",
"import": "./decimal.mjs",
"require": "./decimal.js"
},
"./decimal.mjs": "./decimal.mjs",
"./decimal.js": "./decimal.js",
"./package.json": "./package.json"
},
Do you get the same error if "main": "decimal",
is removed from the package.json?
Downgrading to v10.3.1 fixed it for me. Removing "main": "decimal",
had no effect.
We are installing using yarn@1.22.19
for node v16.14.2.
Importing using,
import Decimal from 'decimal.js';
&
import { Decimal } from 'decimal.js';
Changing those from one to another had no effect.
Thanks for letting me know.
I wonder if adding
"./decimal": "./decimal"
to the package.json exports
would fix the issue.
I.e.
"exports": {
".": {
"types": "./decimal.d.ts",
"import": "./decimal.mjs",
"require": "./decimal.js"
},
"./decimal.mjs": "./decimal.mjs",
"./decimal.js": "./decimal.js",
"./package.json": "./package.json",
"./decimal": "./decimal"
},
I'm facing the same issue.
Adding
"./decimal": "./decimal"
did not work (it results in a new error Cannot find module '/[...]/node_modules/decimal.js/decimal'
).
However, adding
"./decimal": "./decimal.js"
or
"./decimal": {
"types": "./decimal.d.ts",
"import": "./decimal.mjs",
"require": "./decimal.js"
}
fixes the issue.
@ReneZeidler
Thanks for letting me know. Fixed in v10.4.1.
A few days ago I started seeing this error on multiple of our typescript projects (using Nestjs). I think it has something to do with using Namespaces.
I was wondering if this was an issue with our project builds or something related to Decimal.js itself? It's odd that across multiple projects with different setups we were seeing the same error from the same package, which is what brought me here. Any insight would be greatly appreciated.
Thanks.