3

I tried searching internet, couldn't find details how can I load a npm package to yew.

I am trying to load @polkadot/extension-dapp ( code docs)

#[wasm_bindgen(module = "/node_modules/@polkadot/extension-dapp/index.js")]
extern "C" {
    #[wasm_bindgen]
    pub fn web3Enable(originName: String) -> JsValue;
} 

It gives error: Uncaught TypeError: Failed to resolve module specifier "@polkadot/util". Relative references must start with either "/", "./", or "../".

Amiya Behera
  • 2,210
  • 19
  • 32
  • 1
    Done it with converting to individual js files: https://github.com/amiyatulu/polkadot-extension-on-yew – Amiya Behera Aug 26 '22 at 04:33
  • 1
    Are you sure you are not missing a dot at begin of the path? I highly doubt you have a node_modules fólder in the root of your filesystem. – Piranna Feb 07 '23 at 02:44
  • @AmiyaBehera did you also figure out how to import any other npm packages from node_modules? i'm encountering the same original issue as you... but i'm trying to import @polkadot/api – Luke Schoen May 13 '23 at 10:25
  • @AmiyaBehera i found a solution that works for importing npm packages from node_modules https://stackoverflow.com/a/75717991/3208553 – Luke Schoen May 13 '23 at 11:16
  • Ya successfully implement node package (@polkadot/api). Thank you. – Amiya Behera May 16 '23 at 08:40

0 Answers0