bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.67k stars 2.1k forks source link

Npm error when installing version 4.0.1 #1150

Closed silence-may closed 6 years ago

silence-may commented 6 years ago

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 mint-ui@2.2.13 requires a peer of vue@^2.3.0 but none is installed. You must install peer dependencies yourself. npm WARN test@1.0.0 No description npm WARN test@1.0.0 No repository field.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! tiny-secp256k1@1.0.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the tiny-secp256k1@1.0.0 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!

silence-may commented 6 years ago

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?

dcousens commented 6 years ago

@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.

fanatid commented 6 years ago

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

boris-kolar commented 6 years ago

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.

silence-may commented 6 years ago

@fanatid I only installed these two plugins.

silence-may commented 6 years ago

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

boris-kolar commented 6 years ago

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

prahaladbelavadi commented 6 years ago

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:

dcousens commented 6 years ago

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.

boris-kolar commented 6 years ago

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")'
dcousens commented 6 years ago

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