rollup-watch
rollup-watch copied to clipboard
Could not load module, "ENOENT: no such file or directory"
Receiving this error while trying to use nanoid, on Rollup version 0.63.4.
[!] Error: Could not load crypto (imported by C:\.dev\js\profiles\node_modules\nanoid\random.js): ENOENT: no such file or directory, open 'crypto'
Loading the JS in the browser shows this error in the console:
TypeError: random is not a function
I tried using rollup-plugin-node-builtins, and while the rollup error went away, the console error in the browser remains.
My index.js:
import nanoid from 'nanoid';
const a = nanoid(11);
console.log(a);
My rollup.config.js:
const config = {
input: './src/index.js',
output: {
file: './public/app.js',
format: 'iife',
sourcemap: true
},
plugins: [
nodeResolve(),
commonjs(),
buble(),
],
};
export default config;
me too