# ReferenceError: self is not defined

**URL:** <https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212>\
**Category:** Technical\
**Created:** [June 14, 2022, 1:30pm UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212 "2022-06-14T13:30:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abriceno](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@abriceno](https://community.blockcerts.org/u/abriceno)\
**Post date:** [June 14, 2022, 1:30pm UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212/1 "2022-06-14T13:30:22Z")

</div>

Hi all, I am running the [server.js](https://github.com/blockchain-certificates/cert-verifier-js/blob/master/test/manual-testing/node/server.js) sample code for NodeJS and I get the following error:

```auto
/cert-blockchain/node_modules/@blockcerts/hashlink-verifier/lib/cjs/hashlink/crypto-browser.js:5
exports.default = (self.crypto || self.msCrypto);
                             ^

ReferenceError: self is not defined
    at Object.<anonymous> (/cert-blockchain/node_modules/@blockcerts/hashlink-verifier/lib/cjs/hashlink/crypto-browser.js:5:20)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/cert-blockchain/node_modules/@blockcerts/hashlink-verifier/lib/cjs/hashlink/codecs.js:35:42)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

```

My NodeJS version is v16.15.0 and my cert-verifier-js version is 5.13.0.

The documentation indicates that it is possible to run cert-verifier-js from [NodeJS](https://github.com/blockchain-certificates/cert-verifier-js#running-in-nodejs)

Can anyone help me?

Thanks

---

<div class="post-metadata">

**Author:** ![lemoustachiste](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@lemoustachiste](https://community.blockcerts.org/u/lemoustachiste)\
**Post date:** [June 15, 2022, 4:01pm UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212/2 "2022-06-15T16:01:06Z")

</div>

The code should be available from `@blockcerts/cert-verifier-js/lib`.  
The build tests seem to be working so I haven’t noticed any issue, but please confirm if that works, the issue seems to be coming from a sub package.

---

<div class="post-metadata">

**Author:** ![abriceno](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@abriceno](https://community.blockcerts.org/u/abriceno)\
**Post date:** [June 15, 2022, 4:17pm UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212/3 "2022-06-15T16:17:29Z")

</div>

I installed the dependencies on the **@blockcerts/cert-verifier-js** path using the **npm install --legacy-peer-deps** command and I get the same error.

I don’t know if this is the right thing to do because I am new to NodeJS. Please guide me about it.

---

<div class="post-metadata">

**Author:** ![lemoustachiste](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@lemoustachiste](https://community.blockcerts.org/u/lemoustachiste)\
**Post date:** [June 27, 2022, 7:23pm UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212/4 "2022-06-27T19:23:13Z")

</div>

I have tracked this issue here: [Node build is broken · Issue #1380 · blockchain-certificates/cert-verifier-js · GitHub](https://github.com/blockchain-certificates/cert-verifier-js/issues/1380)

---

<div class="post-metadata">

**Author:** ![kevinkatler](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kevinkatler](https://community.blockcerts.org/u/kevinkatler)\
**Post date:** [November 2, 2022, 11:26am UTC](https://community.blockcerts.org/t/referenceerror-self-is-not-defined/3212/5 "2022-11-02T11:26:01Z")

</div>

If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is [not defined](http://net-informations.com/jq/iq/defined.htm) error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.

To solve this error: Load your library at the beginning of all your scripts.

There can be multiple other reasons for this issue:

- Conflict with Other Libraries
- Path to your library included is not correct
- Llibrary file is corrupted
- Working offline (when you use CDN)
