random
random copied to clipboard
Cannot import successfully
Cannot import successfully. How do I solve this?
I'm using it like so.
import random from 'random'
//...
const get = () => {
const num = random.uniformInt(0, 100)();
return num;
}
but it shows me this:
ERROR in ./node_modules/random/dist/esm/index.esm.js 1:0-30
Module not found: Error: Can't resolve './random' in 'myprojects\project\node_modules\random\dist\esm'
Did you mean 'random.js'?
BREAKING CHANGE: The request './random' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
I tried these but didnt work:
import random from 'random.js'
import random from 'random.ejs'
import random from 'random.esm.js'
import random from 'random.mjs'
Hi @mrkresnofatih! This is a known issue (see #35). The configuration for the package entrypoints are sub-optimal. There are several PR's open with fixes. I anticipate a patch will be released soon.
Please solve this as soon as possible..
Hi @transitive-bullshit can we get the fix for this issue merged?
Please upgrade to v4 which now exports an ESM module only. Sorry for the issues on previous versions.