Blockstatck-cli problem

  1. git clone https://github.com/blockstack/blockstack.js
  2. cd blockstack.js/
  3. git checkout -b feature/stack-transactions
  4. npm install -g
  5. npm link
  6. npm run build
  7. cd …
  8. git clone https://github.com/jcnelson/cli-blockstack
  9. cd cli-blockstack
  10. npm link blockstack
    11.npm install( that have a problem)

When I execute step 11 that have problem:

npm ERR! path /usr/local/lib/node_modules/blockstack-cli/lib/index.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod ‘/usr/local/lib/node_modules/blockstack-cli/lib/index.js’
npm ERR! enoent This is related to npm not being able to find a file.

Hey @MrLiu,

Sorry to hear you’re having problems. Can you try these steps in place of steps 10 and 11?

$ cd cli-blockstack
$ npm install
$ npm link blockstack

This will install the released version of blockstack.js as well as the rest of the dependencies. From there, you should be able to run npm link blockstack to link in the feature/stacks-transactions branch you installed earlier.

@jude
Thank you for your prompt reply,How do I use cli when I finish executing “npm link blockstack”。 This problem has been bothering me for some time, I have not found detailed tutorial materials except the video in Youtube ,but I can’t use youtube in my country. if you have time ,I wish you can provide a detail tutorial about how to install CLI. that will help foreigners like me understand the use blockstack ,thank you again

Hi @MrLiu

There are some examples at https://testnet.blockstack.org/ that you might find useful

Hi @jude

I also have issues using blockstack-cli. Following these steps:

  1. git clone https://github.com/blockstack/blockstack.js
  2. cd blockstack.js/
  3. git checkout -b feature/stack-transactions
  4. npm install
  5. npm link
  6. npm run build
  7. cd …
  8. git clone https://github.com/jcnelson/cli-blockstack
  9. cd cli-blockstack
  10. npm link blockstack
    11.npm install
  11. npm link

The compilation works, but when starting blockstack-cli, I get the following error:

/Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/utils.js:354
return ecKeyPair.publicKey.toString(‘hex’);
^

TypeError: Cannot read property ‘toString’ of undefined
at getPublicKeyFromPrivateKey (/Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/utils.js:354:30)
at Object. (/Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/auth.js:37:63)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/cli.js:45:13)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)

Changing “blockstack”: "^18.0.0 " to “blockstack”: “^18.0.4” in the package.jsonfile, and recompiling, blockstack-cli works, and returns the set of possible command. However, trying for example

Ya-L-2:cli-blockstack yalb$ blockstack-cli balance 1JcnAyf9dSkRbgi2vJKY47Hz3KoEazjSSt

returns the following error

TypeError: network.getAccountTokens is not a function
at /Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/cli.js:2128:20
at
at process._tickCallback (internal/process/next_tick.js:189:7)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
network.getAccountTokens is not a function

Any idea what could be wrong?

Hey @yannael_leborgne.id,

Looks like you’re blockstack.js version is 18.0.4 still. It needs to be 19.0.0 (achieved with the npm link blockstack), since this version defines the network.getAccountTokens() method.

Hi @Jude

I just tried using the updated instructions at https://github.com/jcnelson/cli-blockstack.

Note: Using sudo gave write access errors. I therefore used the following

$ git clone https://github.com/blockstack/blockstack.js
$ cd blockstack.js
$ git checkout feature/stacks-transactions # or feature/stacks-transactions-authResponse-1.3
$ npm install
$ npm link

This properly compiles the 19.0.0 version, and links it in /usr/local/lib/node_modules

Then, running

$ git clone https://github.com/jcnelson/cli-blockstack
$ cd cli-blockstack
$ npm install
$ npm link blockstack

Properly compiles cli-blockstack, and properly links blockstack to version 19.0.0 in local node_modules folder.

However, after running npm run build, the blockstack version in the local node_modules folder is back to “18.0.4”

Finally running npm install compiles, but with blockstack 18.0.4, and I still get the error

Ya-L-2:cli-blockstack yalb$ blockstack-cli balance SPZY1V53Z4TVRHHW9Z7SFG8CZNRAG7BD8WJ6SXD0
TypeError: network.getAccountTokens is not a function
at /Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/cli-blockstack/lib/cli.js:2128:20
at
at process._tickCallback (internal/process/next_tick.js:189:7)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
network.getAccountTokens is not a function

I also tried to change the package.json in cli-blockstack so it requires blockstack version 19.0.0 (after executing ‘npm link blockstack’, so the local node_modules folder has blockstack 19.0.0);

Surprisingly, running ‘npm install’ now tells me that blockstack 19.0.0 cannot be found

Ya-L-2:cli-blockstack yalb$ npm install
npm ERR! code ETARGET
npm ERR! notarget No matching version found for blockstack@^19.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn’t exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of ‘blockstack-cli’
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/yalb/.npm/_logs/2018-10-01T07_42_16_216Z-debug.log

Node version: 8.12.0
npm version: 6.4.1

Hey @yannael_leborgne.id,

If you just execute these steps, does it work?

$ git clone https://github.com/jcnelson/cli-blockstack
$ cd cli-blockstack
$ npm install
$ npm run build
$ npm link blockstack

Hi @Jude

I get the following error message:

Ya-L-2:cli-blockstack yalb$ blockstack-cli
module.js:550
throw err;
^

Error: Cannot find module ‘jsontokens’
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/Users/yalb/Projects/CurrentProjects/Blockchain/Blockstack/mybs/blockstack.js/lib/auth/authApp.js:21:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)

I tried installing it from the Blockstack browser Docker container (https://github.com/blockstack/blockstack-browser/releases/download/v0.34.1/Blockstack-for-Linux-v0.34.1.sh)

Using

$ git clone https://github.com/blockstack/blockstack.js
$ cd blockstack.js/
$ git checkout -b feature/stack-transactions -authResponse-1.3
$ npm install
$ npm link
$ npm run build
$ cd …

$ git clone https://github.com/jcnelson/cli-blockstack
$ cd cli-blockstack
$ npm install
$ npm run build
$ npm link blockstack

Gives this error

root@cd3087608b6a:/src/cli-blockstack# node ./lib/index.js
internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module ‘blockstack’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (/src/cli-blockstack/lib/utils.js:48:19)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)

$ cd blockstack.js/
$ git checkout -b feature/stack-transactions -authResponse-1.3
$ npm install
$ npm run build
$ sudo npm link  # must link to /usr/lib/node_modules, /usr/local/lib/node_modules, wherever

You need to run npm install, npm run build, and then sudo npm link (i.e. this directory needs to get symlinked to your global node_modules install path, such as /usr/lib/node_modules or /usr/local/lib/node_modules).

Once that’s done, then you should be able to build the CLI with

$ cd cli-blockstack
$ npm install
$ npm run build
$ npm link blockstack
$ sudo npm link # installs /usr/bin/blockstack-cli

I tested this on a fresh Ubuntu VM and it worked as expected.

Hi @jude

What kind of Ubuntu VM did you use?

Unfortunately, I still get errors. Trying to pin down the issue, here is a minimalistic setup:

  1. Use Docker node.js official container, node:8.12.0-jessie

docker pull node:8.12.0-jessie
docker run -it node:8.12.0-jessie bash

  1. Install sudo, add node user to sudo group, change user to node and change directory to node home

apt-get update
apt-get install sudo
usermod -aG sudo node
passwd node
su node
cd

  1. Execute the following installation instructions

git clone https://github.com/blockstack/blockstack.js
cd blockstack.js
git checkout -b feature/stack-transactions-authResponse-1.3
npm install
npm run build
sudo npm link

cd …
git clone https://github.com/jcnelson/cli-blockstack
cd cli-blockstack
npm install
npm run build
npm link blockstack
sudo npm link

  1. Run blockstack cli to check the balance of an address

blockstack-cli balance SPZY1V53Z4TVRHHW9Z7SFG8CZNRAG7BD8WJ6SXD0

This returns

node@f67f28f29797:~/cli-blockstack$ blockstack-cli balance SPZY1V53Z4TVRHHW9Z7SFG8CZNRAG7BD8WJ6SXD0
TypeError: network.getAccountTokens is not a function
at /home/node/cli-blockstack/lib/cli.js:2128:20
at
at process._tickCallback (internal/process/next_tick.js:189:7)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
network.getAccountTokens is not a function

Could you try to reproduce ?

Thanks!

I got it to work in a Xenial VM, and I got it to work on Alpine. I can’t get it to work in the docker image you provided – basic functionality appears broken (getting environment-based errors like gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/8.12.0" when in fact the directory exists). Chalk it up to the general jankiness of node.js and npm when it comes to using linked packages :man_shrugging:

Have you tried something more “reliable” like installing the feature/stacks-transactions-authResponse-1.3 branch of blockstack.js globally, instead of trying to link it?

Hi, I have followed the tutorial from here :


to install blockstack cli.
but I am getting this error:

internal/modules/cjs/loader.js:983
throw err;
^

Error: Cannot find module ‘…/lib/index’
Require stack:

  • /usr/local/lib/node_modules/blockstack-cli/cmd/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (/usr/local/lib/node_modules/blockstack-cli/cmd/index.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [ ‘/usr/local/lib/node_modules/blockstack-cli/cmd/index.js’ ]
    }

Hi there @asimmehmood,

Did you use the whole command: sudo npm install -g "https://github.com/blockstack/cli-blockstack#feature/stacks-2.0-tx" ?

It is important to include the sudo in order to gain administrator priveledges, and the #feature/stacks-2.0-tx specifies the correct package to download from Github.

Hi @Stacks_Joe,
I have used this command
sudo npm install -g "https://github.com/blockstack/cli-blockstack#feature/stacks-2.0-tx" --unsafe

Peculiar!

Do you have a Stacks 2.0 testnet node running in another terminal on your machine?

Do you have the latest version of Node.js 8.12.0 installed?

Also what reason are you using the --unsafe command?

@Stacks_Joe, please ignore the --unsafe flag it was to overcome EACCESS issue, for that I have now used NVM.

Now for the main issue, there is no Stacks 2.0 testnet node running at all.
I have Node.js v13.8.0 installed.

Let me tell you one observation of mine, it may help you figure out the problem.

I checked the file which was at the path

"/usr/local/lib/node_modules/blockstack-cli/cmd/index.js"

and it has the following line of code

#!/usr/bin/env node

require(’…/lib/index’);

now as you see it is required index file at path ../lib/index which does not exist.
Did I do the installation right?
Have I missed any step?
also if I use Blockstack-CLI 1.0 it works fine.