<p>I've also come across this error in webpack, but found that it can be ignored if you use a Loader like so:</p>
<pre><code>class Loader {
  async load() {
    if (this._wasm &amp;&amp; this._wasm2) return;
    /**
     * @private
     */
    this._wasm = await import(
      '@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib'
    );
  }

  get Cardano() {
    return this._wasm;
  }
}

export default new Loader();
</code></pre>
<p>Then in your components, this should work:</p>
<pre><code>import Loader from './loader'

/* ... other component code ... */

getAddress() {
      window.cardano.getChangeAddress().then((address) =&gt; { 
        Loader.load() // Note, loading the library here
        this.address = Loader.Cardano.Address.from_bytes( // Now Loader.Cardano resolves
            Buffer.from(address, &quot;hex&quot;)
        ).to_bech32()
      })
}
</code></pre>
<p>As a side note, I've also found it easier to just call <code>Loader.load()</code> in my <code>beforeMount()</code> callback or similar depending on the library you're using.</p>

CC BY-SA 4.0
2021-12-08T09:58:40.803Z
2021-12-08T09:58:40.803Z
Thom
<p>Use node-fetch 2.6.6 and it should work</p>

CC BY-SA 4.0
2021-12-06T00:30:15.660Z
2021-12-06T00:30:15.660Z
Jonathan Fishbein
<p>I'm trying to use a library to access a cardano wallet, right now, I'm in webpack 5 and project run so far until I try to import the cardano library.
It breaks in the same point always:</p>
<pre><code>runtime modules 33.6 KiB 17 modules
modules by path ./node_modules/ 17.5 MiB 49 modules
modules with errors 429 bytes [errors]
  optional modules 78 bytes [optional]
    node:process 39 bytes [optional] [built] [code generated] [1 error]
    node:stream/web 39 bytes [optional] [built] [code generated] [1 error]
  9 modules
./src/index.js 280 bytes [built] [code generated]

WARNING in ./node_modules/@emurgo/cardano-serialization-lib-asmjs/cardano_serialization_lib_bg.js 12128:14-53
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@emurgo/cardano-serialization-lib-asmjs/cardano_serialization_lib.js 2:0-50 2:0-50
 @ ./node_modules/nami-wallet-api/lib/index.js 635:98-148
 @ ./src/index.js 2:23-48

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in node:fs
Module build failed: UnhandledSchemeError: Reading from &quot;node:fs&quot; is not handled by plugins (Unhandled scheme).
Webpack supports &quot;data:&quot; and &quot;file:&quot; URIs by default.
You may need an additional plugin to handle &quot;node:&quot; URIs.
Critical dependency: the request of a dependency is an expression
</code></pre>
<p>If any of you had success using this library and webpack please let me know. </p>
<pre><code>{
  &quot;name&quot;: &quot;webpacktemplate&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;private&quot;: true,
  &quot;dependencies&quot;: {
    &quot;fs&quot;: &quot;0.0.1-security&quot;,
    &quot;html-webpack-plugin&quot;: &quot;^5.5.0&quot;,
    &quot;lodash&quot;: &quot;^4.17.21&quot;,
    &quot;nami-wallet-api&quot;: &quot;^1.1.9&quot;,
    &quot;net&quot;: &quot;^1.0.2&quot;,
    &quot;node-fetch&quot;: &quot;^3.1.0&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;webpack&quot;: &quot;^5.64.4&quot;,
    &quot;webpack-cli&quot;: &quot;^4.9.1&quot;,
    &quot;webpack-dev-server&quot;: &quot;^4.6.0&quot;
  },
  &quot;scripts&quot;: {
    &quot;start&quot;: &quot;webpack serve --open&quot;,
    &quot;build&quot;: &quot;webpack&quot;,
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
  },
  &quot;keywords&quot;: [],
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;
}
</code></pre>

CC BY-SA 4.0
2021-12-04T19:45:57.197Z
I would suggets to import it using a Loder like the Nami Wallet does it. That is the only way I could make it work. Also I would suggest to consider using the browser version.  Also I noticed that the error has to do with fs, i faced the same error but thats related to the way Next.Js Works... If you are using Next.Js .. try following the configuration i use in my project https://github.com/alice1989123/Metahagane . Good luck!
Alicia Basilio
<nami-wallet>
Webpack + Cardano ASM serialization library
# Webpack + Cardano ASM serialization library

(Asked by: username_0 on 2021-12-04)

I'm trying to use a library to access a cardano wallet, right now, I'm in webpack 5 and project run so far until I try to import the cardano library.
It breaks in the same point always:
runtime modules 33.6 KiB 17 modules
modules by path ./node_modules/ 17.5 MiB 49 modules
modules with errors 429 bytes [errors]
  optional modules 78 bytes [optional]
    node:process 39 bytes [optional] [built] [code generated] [1 error]
    node:stream/web 39 bytes [optional] [built] [code generated] [1 error]
  9 modules
./src/index.js 280 bytes [built] [code generated]

WARNING in ./node_modules/@emurgo/cardano-serialization-lib-asmjs/cardano_serialization_lib_bg.js 12128:14-53
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@emurgo/cardano-serialization-lib-asmjs/cardano_serialization_lib.js 2:0-50 2:0-50
 @ ./node_modules/nami-wallet-api/lib/index.js 635:98-148
 @ ./src/index.js 2:23-48

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in node:fs
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Critical dependency: the request of a dependency is an expression

If any of you had success using this library and webpack please let me know. 
{
  "name": "webpacktemplate",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "dependencies": {
    "fs": "0.0.1-security",
    "html-webpack-plugin": "^5.5.0",
    "lodash": "^4.17.21",
    "nami-wallet-api": "^1.1.9",
    "net": "^1.0.2",
    "node-fetch": "^3.1.0"
  },
  "devDependencies": {
    "webpack": "^5.64.4",
    "webpack-cli": "^4.9.1",
    "webpack-dev-server": "^4.6.0"
  },
  "scripts": {
    "start": "webpack serve --open",
    "build": "webpack",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

**Tags:** nami-wallet
> **Comments:**
> **username_1**: I would suggets to import it using a Loder like the Nami Wallet does it. That is the only way I could make it work. Also I would suggest to consider using the browser version.  Also I noticed that the error has to do with fs, i faced the same error but thats related to the way Next.Js Works... If you are using Next.Js .. try following the configuration i use in my project https://github.com/alice1989123/Metahagane . Good luck!  

---

## 2 answers

### Answer by username_2 on 2021-12-08. Score: 1 | Accepted answer

I've also come across this error in webpack, but found that it can be ignored if you use a Loader like so:
class Loader {
  async load() {
    if (this._wasm && this._wasm2) return;
    /**
     * @private
     */
    this._wasm = await import(
      '@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib'
    );
  }

  get Cardano() {
    return this._wasm;
  }
}

export default new Loader();

Then in your components, this should work:
import Loader from './loader'

/* ... other component code ... */

getAddress() {
      window.cardano.getChangeAddress().then((address) => { 
        Loader.load() // Note, loading the library here
        this.address = Loader.Cardano.Address.from_bytes( // Now Loader.Cardano resolves
            Buffer.from(address, "hex")
        ).to_bech32()
      })
}

As a side note, I've also found it easier to just call Loader.load() in my beforeMount() callback or similar depending on the library you're using.


---

### Answer by username_3 on 2021-12-06. Score: 0

Use node-fetch 2.6.6 and it should work


---

