bcoin-org / bcoin

Javascript bitcoin library for node.js and browsers
https://bcoin.io
Other
2.99k stars 814 forks source link

npm install webpack installation error #985

Open mrfoxie opened 4 years ago

mrfoxie commented 4 years ago

npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"14.4.0","npm":"6.14.5"}) npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm64"})

1 package is looking for funding run npm fund for details

pinheadmz commented 4 years ago

Could you provide more context? All I see here is warnings. Webpack config files and scripts were removed from bcoin a while ago: https://github.com/bcoin-org/bcoin/pull/741

mrfoxie commented 4 years ago

I'm trying to install bcoin browser from this site Run a bcoin full node in a web browser I tried it using superuser mode in my system here is the screenshot of it. Screenshot (8) I'm trying to give style to browser section like this Screenshot (9)

pinheadmz commented 4 years ago

Sorry the browser node guide is outdated now, and its such bad practice to run a node in a web browser anyway, its not really worth updating. We should probably just remove it.

You can take a look at this guide that explains how to use bpkg to compile individual modules for the browser: https://bcoin.io/guides/webapp

Or check out this repo, where I use bpkg to compile a bcoin full node into a cleaner bootstrap interface: https://github.com/pinheadmz/mobilebcoin

mrfoxie commented 4 years ago
mkdir <new dir for your app>
cd <wherever your bcoin repo is installed>
bpkg --browser --standalone --plugin [ uglify-es --toplevel ] --name HD \
--output <your new app dir>/HD.js lib/hd/index.js

when I use this comment it gave error Invalid argument: --standalone.

pinheadmz commented 4 years ago

I believe standalone has been replaced with umd please read the documentation here: https://github.com/chjj/bpkg

mrfoxie commented 4 years ago

I tried it didn't work and I got this error

root@kali:/home/kali/bcoin# npm install -g bpkg
/usr/local/bin/bpkg -> /usr/local/lib/node_modules/bpkg/bin/bpkg
+ bpkg@0.6.0
added 1 package from 1 contributor in 8.551s
root@kali:/home/kali/bcoin# npm install -g uglify-es
/usr/local/bin/uglifyjs -> /usr/local/lib/node_modules/uglify-es/bin/uglifyjs
+ uglify-es@3.3.9
added 3 packages from 38 contributors in 3.967s
root@kali:/home/kali/bcoin# pwd
/home/kali/bcoin
root@kali:/home/kali/bcoin# ls
bench  bin  browser  CHANGELOG.md  docs  etc  jsdoc.json  lib  LICENSE  migrate  node_modules  package.json  README.md  scripts  snap  test
root@kali:/home/kali/bcoin# bpkg --browser --umd --plugin [ uglify-es --toplevel ] --name HD \ --output /home/kali/bcoin/browser/HD.js lib/hd/index.js
Error: Cannot find module: '/home/kali/bcoin/ --output'
    at Resolver.resolve (/usr/local/lib/node_modules/bpkg/lib/resolver.js:338:19)

and I'm running as a supper user this is the screenshot Screenshot (12)

pinheadmz commented 4 years ago

This command worked for me:

bpkg --browser --umd --name HD --plugin uglify-es  \
--output /home/pinheadmz/Desktop/work/bpkgtest/bcoin-hd.js lib/hd/index.js

Then create index.html:

<html>
<head></head> 
<body>
test

<script type="text/javascript" src="bcoin-hd.js"></script>
</body>
</html>

Screenshot from 2020-07-29 08-27-14

mrfoxie commented 4 years ago

if I add this HD.js script in browser folder and then include it in index.html wull it work

pinheadmz commented 4 years ago

yup. i think so :-) That's how this works: https://github.com/pinheadmz/bcoin-webapp

mrfoxie commented 4 years ago

its working but there is a question i want to ask can i make like this from this codes https://bcoin.io/browser/

pinheadmz commented 4 years ago

its working but there is a question i want to ask can i make like this from this codes https://bcoin.io/browser/

You would have to do some patching yourself - the browser node guide, as you've discovered, is outdated and the actual webapp hosted on bcoin.io is running a patchset on top of a 2-year-old build of bcoin: https://github.com/pinheadmz/bcoin/commits/browserserver

If you really want to recreate the bcoin.io webapp you can try building it from that branch in my repo. Notice in that branch I've actually built four different bcoin's (testnet/main, spv/full) and commited the webpack output already.

mrfoxie commented 4 years ago

okay i will check and tell you

mrfoxie commented 4 years ago

its working but there is a question i want to ask can i make like this from this codes https://bcoin.io/browser/

You would have to do some patching yourself - the browser node guide, as you've discovered, is outdated and the actual webapp hosted on bcoin.io is running a patchset on top of a 2-year-old build of bcoin: https://github.com/pinheadmz/bcoin/commits/browserserver

If you really want to recreate the bcoin.io webapp you can try building it from that branch in my repo. Notice in that branch I've actually built four different bcoin's (testnet/main, spv/full) and commited the webpack output already.

image as im trying it but i got this error