Advanced Bitcoin Scripting - Discussion

Update:

I installed via Git by using the commands from bcoin’s Getting Started GitHub’s page (in Git bash) :

$ git clone git://github.com/bcoin-org/bcoin.git
$ cd bcoin

package-lock.json still no where to be found.

followed the course’s instruction in the lecture to run node address.js but ‘bcoin’ module cannot be found.

I’m stuck at the moment.

If you cloned the repo in the project file then you will have to change the import paths to relative or you can create a node_modules folder manually in the project folder and copy bcoin there.

**EDIT** : Holy crap. I double backed and ran the commands from Filip's video and it worked... Sorry for bothering, I do not understand what went wrong initially so I can't explain it at the moment... :grimacing: :shushing_face:

@Alko89 Thanks for ever replying so quickly, appreciate your help.

Would you mind elaborating on how to change import paths to relative? I do not understand what that means.

I have tried both working the node address.js command from the Git folder and a academy project folder but faced identical results.

What’s confusing me is that there are already bcoin and node_modules folder present.

1 Like

Its no problem, great that you have figured it out! :raised_hands: I know it cab be hard to begin with these things and bcoin can be quite annoying.

Relative paths simple mean that you provide a full path to the import file, relative to the project folder. You usually do this with files you created. For example if you have a project structure like:

lib/somelib.js
main.js

Then if you want to import somelib.js into main.js file you use the path to the file in the import statement relative to its location: import * from './lib/somelib.js'

1 Like

Screenshot (619)

I am stuck here can anyone help me.
It says still waiting for installer log file…

Hmm, never used npm to install build tools, but this should take a while. How long did you wait?

I waited for an hour.

Try installing build tools from Microsoft instead: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

After a lot of trial and error finally, it worked thank you @Alko89

1 Like

I got the environment setup. But i’m completely lost when you start actually writing the code. In what IDE is this?

You can use any text editor you want. :slight_smile:

1 Like

Hey Guys i need help with installing the “https://github.com/bcoin-org/bcoin” file.

As soon as i try to execute this code “npm install https://github.com/bcoin-org/bcoin” i recieve this message:

C:\Users\leona\AppData\Local\Multisig>npm install https://github.com/bcoin-org/bcoin

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/bcoin-org/bcoin.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\leona\AppData\Roaming\npm-cache_logs\2021-09-17T07_53_43_113Z-debug.log

what am i doing wrong?

Thank you.

I also get this issue… Did you solve ? @coinbit

Seems like an error with the remote server. I tried installing it and worked fine just now.

% npm install https://github.com/bcoin-org/bcoin

changed 9 packages, and audited 35 packages in 30s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

If it still doesn’t work you can try installing the library using git.

Hi

I’m trying to install https://github.com/bcoin-org/bcoin, however, I’m getting the following error:

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Can someone please assist?

Thanks

Do you have git installed and is available in your path?

I’ve just installed git, however, not sure what you mean about being available in your path?

PATH is an OS environment variable that the system uses to find executables. Does it work after you installed it?

hey @Alko89
i keep getting node-gyp rebuild failures when i follow instructions posted around here.
i tried npm install bcoin, which appeared to give me what filip got in the setup lecture; however, running the address.js script threw an error about being unable to find bcrypto.node. when i try manually moving files/folders into bcoin or node_modules and retry, then i usually get something like can’t find bcoin module.

there was a mac specific tutorial up above us somewhere here, but that’s no longer hosted, the script you suggested that involved python gave me the heeby jeebies because last time i installed python it took me a week, and your more recent points seem specific to windows/ubuntu

the main error i keep getting:
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/include/node’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/src’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/deps/openssl/config’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/deps/openssl/openssl/include’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/deps/uv/include’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/deps/zlib’
clang: error: no such file or directory: ‘1/Library/Caches/node-gyp/14.18.0/deps/v8/include’
make: *** [Release/obj.target/torsion/deps/torsion/src/aead.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /Users/weakuser 1/Documents/crypto training/BTC scripting/bcoin/node_modules/bcoin/node_modules/bcrypto
gyp ERR! node -v v14.18.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

if you have any other pointers, i’ll be glad to try them
thanks for considering

edits:
found somewhere that i might have to use

sudo apt-get install build-essential

but apt-get not found

then i realized the computer isn’t escaping the space in my user name … in what file can i manually specify the file-location?

commetnary from the nake-file in the bcrypto folder:

# We have to do some pretty insane escaping to get those backslashes
# and dollar signs past make, the shell, and sed at the same time.
# Doesn't work with spaces, but that's fine: .d files have spaces in
# their names replaced with other characters.
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
  grep -v '^$$'                             |\
  sed -e 1d -e 's|$$|:|'                     \
    >> $(depfile)
rm $(depfile).raw
endef

changing the config.gypi file’s “nadedir” field to just escape the space from there did NOT work…
changing every instance of a space i could find in that folder did NOT work either…
in the documentation, there is this piece of info

## Requirements

- Linux, macOS, or Windows (\*)
- node.js >=v10.0.0
- gpk >= v2 or npm >= v6
- python2 or python3 (for node-gyp)
- gcc/g++ (for leveldb/bdb and secp256k1/bcrypto)
- git

(\*): Note that Bcoin works best with unix-like OSes, and has not yet been
thoroughly tested on Windows. The BSDs and Solaris have also not been tested
yet, but should work in theory.

maybe this is too advanced for me

Have you tried creating another user without spaces in the username? Then install bcoin using github: npm install https://github.com/bcoin-org/bcoin.

Python is required since its used by npm so you will have to install it to be able to use it. You can also install a Linux vm, you shouldn’t have any issues there.

1 Like