Bitcoinjs-lib: Npm error when installing version 4.0.1

Created on 27 Jul 2018  路  11Comments  路  Source: bitcoinjs/bitcoinjs-lib

excuse me ,
when i install the latest version 4.0.1 ,there are some wrong,

C:\Users\75467.node-gyp\8.11.1\x64\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x21EA10 [D
:\test\node_modules\tiny-secp256k1\build\secp256k1.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd D:\test\node_modules\tiny-secp256k1
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of vue@^2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

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.

Please ,how to solve the problem? thank you very much!

how to / question / docs

Most helpful comment

@silence-may yes, with --ignore-scripts it installs (this works for me: npm i --ignore-scripts bitcoinjs-lib).

All 11 comments

I successfully installed version 4.0.1

  1. npm install secp256k1
  2. npm install bitcoinjs-lib

but ,there are anthor question , current of version ,it not dependent on bigi , Does the api change anything?

@fanatid how did installing secp256k1 resolve his issue?
@silence-may are you confident that they were the commands you used?

but ,there are anthor question , current of version ,it not dependent on bigi , Does the api change anything?

Yes, the API has changed completely.
Please read the CHANGELOG.

We use Buffer objects instead of bigi instances for cross compatibility.

@silence-may did you installed something between first attempt of installing bitcoinjs-lib and installing secp256k1? like windows-build-tools?

The build fails on my machine too. It fails when compiling native module. The steps required to make installation succeed are a bit advanced for (it involves installing build tools and python 2.7). Another workaround is installing with "--ignore-scripts" npm option. @dcousens: can you make building native dependencies optional, so the package will install on all systems? Native modules shouldn't be required for those looking to use the library in the browser.

@fanatid I only installed these two plugins.

@boris-kolar, with "--ignore-scripts" npm option can success? Is the method I installed wrong? But I also installed it successfully.

@silence-may yes, with --ignore-scripts it installs (this works for me: npm i --ignore-scripts bitcoinjs-lib).

node-gyp rebuild failed while installing secp256k1 and other crypto dependant libraries because it required python 2.7 as @boris-kolar mentioned.
I ended up creating a virtualenv using anaconda with python 2.7 and installing secp256k1 after.

Reference:

I don't think this is a problem so much as a requirement that maybe could be better documented?

Python 2.7 is required to build the native code at this time.

The problem is: bitcoinjs-lib installation fails if npm can't build native code, which is not required for all projects. A warning instead of failure would be more appropriate (see https://docs.npmjs.com/all#best-practices). Workarounds like --ignore-scripts are cumbersome when bitcoinjs-lib is just a dependency). What about somthing like:

node-gyp rebuild || node -e 'console.log("WARNING: failed to build native code")'

@boris-kolar understandable, but I think in this case explicit is better than the implicit 'opt-in' nature of a warning...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

dakk picture dakk  路  3Comments

silence-may picture silence-may  路  3Comments

coingeek picture coingeek  路  4Comments

zhaozhiming picture zhaozhiming  路  3Comments