Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

zos-lib 2.4.1 installed as dependency for zos 2.3.1 #1075

Closed
jchittoda opened this issue Jul 8, 2019 · 5 comments
Closed

zos-lib 2.4.1 installed as dependency for zos 2.3.1 #1075

jchittoda opened this issue Jul 8, 2019 · 5 comments
Labels

Comments

@jchittoda
Copy link

I had been using zos 2.3.1 in the sample project in one of the chapter in my book https://www.amazon.com/Mastering-Solidity-production-ready-contracts-blockchain/dp/1789532418/ref=sr_1_7?keywords=mastering+solidity&qid=1562604381&s=gateway&sr=8-7.

The instruction to install zos is given as npm install -g zos in the book chapter, however the book is in the final review stage and I can update the command to use npm install -g [email protected], but this command is also broken. As zos 2.3.1 is installing zos-lib 2.4.1 as dependency which brake the build.

Following is the error after installing the zos with command npm install -g [email protected] :

$ zos
/usr/local/lib/node_modules/zos/lib/models/files/ZosNetworkFile.js:18
const log = new zos_lib_1.Logger('ZosNetworkFile');
            ^

TypeError: zos_lib_1.Logger is not a constructor
    at Object.<anonymous> (/usr/local/lib/node_modules/zos/lib/models/files/ZosNetworkFile.js:18:13)
    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)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/zos/lib/models/files/ZosPackageFile.js:12:42)
    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)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/zos/lib/models/dependency/Dependency.js:23:42)
    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)
@jbcarpanelli
Copy link
Contributor

jbcarpanelli commented Jul 8, 2019

Hello, @jchittoda, I'm so sorry to hear this!. This is basically happening because in prior versions to 2.4.0 (this one included) we were setting the zos-lib dependency in the zos package.json file with a caret (ie, ^2.x.y Which means that it will install the latest minor version released, in this case, 2.4.1). We had already fixed this in #1059, in which we pinned the zos-lib version inside the zos package.json file, so you shouldn't face this kind of issues in future versions.

Two possible workarounds to your issue would be:

  1. Install [email protected] before installing [email protected]. This way you make sure that zos will use the 2.3.1 version of zos-lib.

  2. The recommended solution would be just using v2.4.1, which as mentioned above, has the zos-lib version pinned. FWIW, we included some new handy commands for interacting with the blockchain, as well as some outputs improvements and features you may want to check out (changelog here) if you decide to use v2.4.1 over v2.3.1.

Sorry for the inconvenience, and thank you so much for using ZeppelinOS in your book! If you have any other issue or question we will be pleased to help 🙂

@jchittoda
Copy link
Author

jchittoda commented Jul 8, 2019

Thanks @jcarpanelli for quick reply.

Unfortunately solution 1 didn't work. I did run the following commands but still the same problem:

$ npm uninstall -g zos
$ npm install -g [email protected]
$ npm install -g [email protected]

I would have to update the whole chapter of the book to adopt for solution 2, which is to use the latest 2.4.1 version. The book is in the final review stage. I will check with publisher, if I can re-write it.

@jbcarpanelli
Copy link
Contributor

jbcarpanelli commented Jul 8, 2019

Unfortunately solution 1 didn't work. I did run the following commands but still the same problem:

True, it doesn't work if you install the package globally, but it should work when installing it locally. Could you please run:

in a project and then run npx zos --help to see if it's working? I've just tested it and seems to be working fine, but you will have to add the npx prefix to all zos calls (e.g., run npx zos create instead of zos create).

I would have to update the whole chapter of the book to adopt for solution 2, which is to use the latest 2.4.1 version. The book is in the final review stage. I will check with publisher, if I can re-write it.

If you decide to go with 2), Take into account that the only breaking change we introduced was removing the zos status command, which was already broken. Apart from that, the usage between 2.3.1 and 2.4.1 is the same, even though:

  • we improved almost all the outputs
  • we introduced our own compiler, so no truffle needed
  • If the project wasn't initialized with truffle, you will see a networks.js instead of a truffle-config.js, which saves almost the same info as the truffle-config file.

EDIT: Also, running npm install --global [email protected] [email protected] worked for me (note that I installed both at the same time instead of separately)

@jchittoda
Copy link
Author

Thanks @jcarpanelli the commands did worked on my machine as well. Thanks for the solution.

@jbcarpanelli
Copy link
Contributor

Glad you solved it 🎉! I'm closing this issue then. If you face any other problem, please do not hesitate to reopen it and drop your questions/concerns!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants