<p>Your file is in the directory:</p>

<pre><code>…/hash2.js
</code></pre>

<p>while the script module is in</p>

<pre><code>…/src/script.js
</code></pre>

<p>The relative path between these two would be <code>./src/script</code> while your file is prescribing to find it in <code>../../script</code>.
Once you correct the relative path, your program should be able to find the module.</p>

CC BY-SA 4.0
2018-06-18T09:29:49.570Z
I was trying to do that, but the only 'script' I could find is a .js file under the subfolder /src. 

Here are some screenshots. 

https://i.imgur.com/F8PMdmH.png

https://i.imgur.com/1fgdo6U.png

Maybe I am entering the wrong path or that is not the .js file required?
Robert
CC BY-SA 4.0
2018-06-18T23:12:16.030Z
And what is the location of your file?
Murch
CC BY-SA 4.0
2018-06-18T23:47:13.930Z
This one: https://i.imgur.com/F8PMdmH.png

hash2.js
Robert
CC BY-SA 4.0
2018-06-18T00:04:04.747Z
2018-06-19T20:12:02.457Z
2018-06-19T20:12:02.457Z
Murch
<p>I am trying to run this code with node and bitcoinjs-lib but I keep getting missing lib. </p>

<p>Any idea what am I missing?</p>

<p>I am on a Windows Server 2016. I try to create a P2SH address by hashing a redeemScript.</p>

<pre><code>// OP_HASH160 {scriptHash} OP_EQUAL
var bitcoin = require('bitcoinjs-lib')
var bscript = require('../../script')
var types = require('../../types')
var typeforce = require('typeforce')
var OPS = require('bitcoin-ops')

function check (script) {
  var buffer = bscript.compile(script)

  return buffer.length === 23 &amp;&amp;
    buffer[0] === OPS.OP_HASH160 &amp;&amp;
    buffer[1] === 0x14 &amp;&amp;
    buffer[22] === OPS.OP_EQUAL
}
check.toJSON = function () { return 'scriptHash output' }

function encode (scriptHash) {
  typeforce(types.Hash160bit, scriptHash)

  return bscript.compile([OPS.OP_HASH160, e216c9ev2d0drec3xxxxxxxxxxxxxxa3b5576d9176, OPS.OP_EQUAL])
}

function decode (buffer) {
  typeforce(check, buffer)

  return buffer.slice(2, 22)
}

module.exports = {
  check: check,
  decode: decode,
  encode: encode
}
</code></pre>

<p>Error is this below, but couldn't find this lib 'script'. </p>

<pre><code>Error: Cannot find module '../../script'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.&lt;anonymous&gt; (C:\Program Files\Bitcoin\rob\hash2.js:3:15)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
</code></pre>

<p>Thanks!</p>

<bitcoinjs>
Bitcoinjs module missing issue
Robert
# Bitcoinjs module missing issue

(Asked by: username_0 on 2018-06-17)

I am trying to run this code with node and bitcoinjs-lib but I keep getting missing lib. 
Any idea what am I missing?
I am on a Windows Server 2016. I try to create a P2SH address by hashing a redeemScript.
// OP_HASH160 {scriptHash} OP_EQUAL
var bitcoin = require('bitcoinjs-lib')
var bscript = require('../../script')
var types = require('../../types')
var typeforce = require('typeforce')
var OPS = require('bitcoin-ops')

function check (script) {
  var buffer = bscript.compile(script)

  return buffer.length === 23 &&
    buffer[0] === OPS.OP_HASH160 &&
    buffer[1] === 0x14 &&
    buffer[22] === OPS.OP_EQUAL
}
check.toJSON = function () { return 'scriptHash output' }

function encode (scriptHash) {
  typeforce(types.Hash160bit, scriptHash)

  return bscript.compile([OPS.OP_HASH160, e216c9ev2d0drec3xxxxxxxxxxxxxxa3b5576d9176, OPS.OP_EQUAL])
}

function decode (buffer) {
  typeforce(check, buffer)

  return buffer.slice(2, 22)
}

module.exports = {
  check: check,
  decode: decode,
  encode: encode
}

Error is this below, but couldn't find this lib 'script'. 
Error: Cannot find module '../../script'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object. (C:\Program Files\Bitcoin\rob\hash2.js:3:15)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

Thanks!

**Tags:** bitcoinjs


---

## 1 answers

### Answer by username_1 on 2018-06-18. Score: 1 | Accepted answer

Your file is in the directory:
…/hash2.js

while the script module is in
…/src/script.js

The relative path between these two would be ./src/script while your file is prescribing to find it in ../../script.
Once you correct the relative path, your program should be able to find the module.

> **Comments:**
> **username_0**: I was trying to do that, but the only 'script' I could find is a .js file under the subfolder /src.   Here are some screenshots.   https://i.imgur.com/F8PMdmH.png  https://i.imgur.com/1fgdo6U.png  Maybe I am entering the wrong path or that is not the .js file required?  
> **username_1**: And what is the location of your file?  
> **username_0**: This one: https://i.imgur.com/F8PMdmH.png  hash2.js  

---

