Include BItcoinJS library in electron project - node.js

I was wondering how to include the Bitcoin JS Library in my electron project. I tried running npm install inside the project directory and creating a var to use it but it does not work for some reason.

Do you have a package.json in your project directory? If so, does it have Bitcoin JS inside the dependencies:? If not, run npm init and fill out the fields that it asks for or just hit enter several time to leave them blank. After that you should have a package.json file. Now run npm install bitcoinjs-lib --save. You should now have BitcoinJS in your node_modules folder and it should be included as a dependency in your package.json.

Related

Node is not getting installed and it is showing error

I was installing node by using the command on cmd npm install and I got following message
enter image description here
Please help me that how I can solve this issue.
npm stands for node package manager which is used to install external packages or npm modules or libraries hosted on NPM. To get started with a Node JS Project you will need index.js and hit npm init, this will initialise your Node JS Project with auto genreated package.json.
Majorly Node JS, React JS or Angular contains following files:
index.js/server.js(Entry File)
package.json (modules/packages/libraries used in project and script can be written to run your project in different envs)
node_modules (which is auto generated and contains all installed modules listed in package.json)
According to your error message you don't have a package.json file so you need to initialize npm before installing node in your directory.
Initialize it with npm init.
Npm documentation
Step 1- First install Node from https://nodejs.org/en/download/.
Step 2- Now go to your project file cd project.
Step 3- Type the command npm init in console.
Step 5- Now you can see package.json file in your project.
Finish- Now you can install any package by using "npm install packageName" command.

Can't update dependency library when code was changed in npm

I just started project react native. I created react native module by command npm install react-native-my-library --save, then run npm install I see it exist in node_module folder.
But when I change code in react native module, and remove folder node_module and run npm install again to update in node_module, it also doesn't update new code that I changed in native module.
Any body can help me to update code in node module folder.
Thanks so much!

How to keep WebRTC adapter.js updated in a project using npm

I am confused about how to make use of npm to keep the adapter.js updated in my project.
I have followed the instructions on https://github.com/webrtc/adapter and get the webrtc-adapter installed using the node command npm install webrtc-adapter.
A directory of node_modules is created and inside there are package.json, out folder, and other files and folders. Since the adapter.js is inside the out folder, I have to copy it to my project libraries folder lib/js/adapter.js.
However, if I run the npm update in the future, it should only update the adapter.js inside the node_modules/out but not lib/js/adapter.js. Then I have to copy it again. Is there anyway I could make the update apply to the lib/js/adapter.js directly?
Thank you.
The webrtc samples repository solves this by having an postinstall npm hook. See here

using a coffeescript node module in a nodejs project

I am playing with a node module called filings
when I first used it, I did a git clone to get that project into a local directory, where I ran npm install and then grunt to build all of the coffeescripts into JS and get dependencies installed.
That works fine and I end up with a /lib directory with 13 files in it.
Now, i'm trying to use that module within a separate node project, so I installed it with npm install filings and a node_modules/filings/lib directory was created, but it only has 6 files in it, and a bunch of functionality is missing.
I've never installed a coffeescript node module into a regular node project before, is there something I can do to get it to properly build within my project?
This is a problem with the package on npmjs.org: If we clone a module from the repository, install it, and make package with npm pack then we get a very different contents of the package to install than the package manager on the site:
http://registry.npmjs.org/filings/-/filings-0.2.0.tgz
coffee-script require (generally spoken)
you can require coffee-script files from a javascript-file if you use coffee-script/register before.
therefore you need to install coffee-script locally:
$ npm install coffee-script --save
and use it in your code:
require('coffee-script/register');
require('youre-coffee-script-module');
using the filings-module
basic setup of filings
the module itself has its main-script set to ./lib/filings.js
the lib-folder is compiled by the grunt-task publish
the publish-Task itself is triggered via the prepublish-script. so anytime the package-auther publishes his package via npm publish the lib-sources are build, an afterwards the compiled package is published.
in the .npmignore file all the source and testfiles are ignore, and therefore not published to npm!
how to fix your problem
i just see 2 more or less clean possibilities:
open an issue, and ask the package-auther to publish a new version to npm
create a fork, and use the fork
a) fork the repo
b1) add a postinstall-Property which runs the grunt-default-task grunt:
"scripts": {
"postinstall": "grunt"
}
or b2) create a index.js file where you require the coffee-sources like i pointed out above
c) install the package from your repo: npm install git+ssh://git#github.com:YOURGITHUBUSERNAME/filings.git
d) maybe create a pull-request if you do version b2

How generate nodejs express dependencies package.json

As I started to develop my first nodejs express application, I added many packages with npm.
I would like to know if there is a way to generate a package.json file containing all the current dependencies or the list of the current packages under the nodes_modules directory.
Just run npm init in the same directory as your project.
You'll be asked a list of questions (name, version, description, etc.) and once complete, it will generate a package.json file with all of the dependencies as currently installed in the node_modules directory.
Run npm list to see what you have installed. Run npm shrinkwrap to build a npm-shrinkwrap.json file, which you can use as a starting reference to build a proper package.json. My workflow is always to update package.json and then run npm install. I never run npm install foo to get some package because it creates risk of forgetting to add it to package.json and then having your application fail to start on deployment.
Updated to add: These days I do run npm install --save foo or npm install --save-dev foo since I have now decided the ~0.4.3 version numbers it adds to package.json are better than my former preference for 0.4.x since the ~ gives you a more precise minimum version number.

Resources