Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

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

@kevinfiol

Description

@kevinfiol

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions