Import npm module


I’m trying to import an npm module to Observable notebooks. I tried different ways to package the module. I used babel to build main/browser/module packages.

I also try to use webpack with babel-loader to build the npm package. Here’s the link to the current version:


I compare the output code on It looks similar to other packages like d3.

None of these versions can be imported to an Observable notebook. I can import them into a React project.

Does anyone know why I can’t import my module?


Phuoc Do

It seems like you’ve bundle react, and react uses process.env to set production/dev

similiar problem with folks using rollup to bundle react

1 Like

@radames thanks for the links. I tried a few things. When I bundle react with the library, Observable loads the library without errors. When I don’t bundle react with the library, I get “invalid module” with process.env. I think the common practice is to not bundle react.

vidajs@0.0.9 (with react, no error)
vidajs@0.0.11 (without react, “invalid module” error)

hi @dnprock I guess you’re right, you could import react separated.

look at this pattern here

1 Like