rollup-watch icon indicating copy to clipboard operation
rollup-watch copied to clipboard

Could not load module, "ENOENT: no such file or directory"

Open kevinfiol opened this issue 6 years ago • 1 comments

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;

kevinfiol avatar Sep 26 '18 16:09 kevinfiol

me too

ycjcl868 avatar Oct 06 '18 07:10 ycjcl868