How import NPM files outside of NPM into NextJS

41 Views Asked by At

I am using an NPM package called rdkit for my NextJS project. It is basically a emscripten version of the C++ RDKit package. I built the wasm files seperately and now I want to use those file seperately.

Previously I would just import the one function like this:

import initRDKitModule from "@rdkit/rdkit";

I have tried just plainly importing the JS file at a component level but I run into this issue:

Module not found: Can't resolve 'fs'
   6 | function(moduleArg = {}) {
   7 | 
>  8 | var Module=moduleArg;var 

I import the module like this:

import initRDKitModule from "./rdkit_latest_build/RDKit_minimal"

I had previously used this starter. I have also tried next scripts and then tried accessing from the window object. But that does not work either. Yes, I have made sure it is run at a browser level with next dynamic imports but still.

Any help would be lovely.

0

There are 0 best solutions below