How to configure package.json to add a "self compiled binary" as a dependency? - json

I am very new to the concept of npm-install. Please throw some insights into where I might be going wrong. I have a .js file through which I am supposed to invoke a binary with some command line arguments.I did write package.json setting the main parameter to the javascript file and I am using preinstall script that compiles the code and creates a binary that is supposed to be used by my java script file.
Couple of questions:
How do I make package.json take this compiled binary as dependency for the js file?
npm install runs fine for me but I do not see any output folder whatsoever. I was hoping it would generate a .node_module in pwd and copy the contents onto bin/ folder in that. May be, I am missing something.
npm info prepublish test#0v.0.1
npm verb from cache <pwd>/package.json
npm verb readInstalled returning test#0.0.1
npm verb exit [ 0, true ]
npm info ok
Can someone please through some insights into this issue?

You don't have to include your binary file in package.json. If you're using Express, put it in the node-modules folder within the parent directory. Otherwise, you can either specify the whole path to the file where you call it or put the file in the parent directory. For global installations, the node-modules folder is usually created at: C:\Users\[Username]\AppData\Roaming\npm\node_modules.

I figured out a way to handle it. Using a js module and using my node as required in that module causes npm to setup my node in node_modules/ folder. I used a pre-install shell script to compile my binary and used the relative path to use the binary upon execution.
Thanks for all who replied.

Related

How do I install a driver in Erlang? (Specifically MySQL-otp driver)

From the documentation this driver looks great. I don't know how to install it so that I can use it though. I read somewhere that I should maybe use rebar? I looked at that documentation though and it appears to have the opposite problem. It says how to install it, but not how to use it.
Update
So it looks like after installing rebar, I can add the lines
{deps, [
{mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
{tag, "1.3.3"}}}
]}.
to my file rebar.config. I don't know what this does though. Do I have to compile or make this file now? Does rebar.config have to be in the same directory as my project? Right not the path to rebar.config is ~/rebar/rebar.config
Is it all correct to place my project so that it is a sibling to rebar in the file hierarchy?
Update
I ran ./rebar get-deps with the rebar folder and got
Pulling mysql from {git,"https://github.com/mysql-otp/mysql-otp",
{tag,"1.3.3"}}
Cloning into 'mysql'...
==> mysql (get-deps)
I still don't really know what this means though, and when I try compiling my erlang file I receive the result.
c(erlangFile.erl).
{error,non_existing}
rebar is a build tool for erlang.Please go through https://github.com/rebar/rebar/wiki/Rebar-commands for the commands.
After getting dependency, "rebar compile" is required to compile it.
For using the beam files, you have to give output beam path using Add Path to Erlang Search Path?
these methods.
Then you will be able to use it in your code.
Download your package, in this case
git clone https://github.com/mysql-otp/mysql-otp.git
Download a tool called rebar
git clone git://github.com/rebar/rebar.git
cd rebar
./bootstrap
Add the following to rebar/rebar.config
{deps, [
{mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
{tag, "1.3.3"}}}
]}.
Within the rebar/mysql-otp directory run
./rebar get-deps
Then within the same directory, run
./rebar compile
This will put a bunch of .beam files and .app file into the ebin/ directory
Next add the ebin/ directory to your path. You can update your $ERL_LIBS environment variable, run an include command within the erlang console like
1> code:add_pathz("~/rebar/mysql-otp/ebin").
or
1> code:add_pathz("rebar/mysql-otp/ebin")
And theres a few other ways to add it to your Erlang path.
Also, make sure mysql is also installed
Heres a few links with mysql installation instructions that worked for me
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7
No package msyql-server available

How to add package.json file to built react app?

If use npm build command to build a react app for production environment, we can get a build named folder. There are html, css and JavaScript in it, but the package.json file doesn’t exists.
If we use this file to set http proxy endpoint to connect API, we can’t run the app well because the endpoint can’t be found.
How to deal with this json file rightly in this case?
First if you have package.json of some Node-React application you can run in example windows CMD (terminal console) and make some folder there you put this package.json and navigate to this folder and then, there typing npm install. On this away you can prepare all what is need for this Node-React app. Exactly with this command starting make node_modules folder there stat install need package. Next step is make folders: src and public, there you put next file :
on Src folder App.js, index.js, App.css
on public folder index.html.
That is because in this package.json exists all what is need for starting application, but if you menually build package.json this can make with run npm.
init in CMD.
Use Proxy in package.json file you can use for example if you send some data in case client-server app. There you have in client for HTTP request axios, on server side express. In package.json file add row "proxy":"http://localhost:3001"
from server. For that plz. look How to set port for express server dynamically?

Creating json file inside a specific directory using terminal

I'm trying to create my Starter Pack Setup and I need to install NPM dependencies. I should create a json file in: /Users/matteomattiussi/Documents/Udemy/Bootstrap/bs4projects/bs4starter
but I don't know how do it because I always getting the json file in:
/Users/matteomattiussi/package.json
Can someone help me, please?
In order to create a package.json file in /Users/matteomattiussi/Documents/Udemy/Bootstrap/bs4projects/bs4starter (if the directory already exists and you have npm installed):
cd /Users/matteomattiussi/Documents/Udemy/Bootstrap/bs4projects/bs4starter
npm init
In using package.json:
This will initiate a command line questionnaire that will conclude
with the creation of a package.json in the directory you initiated the
command.
You can use online JSON compiler and then download it in your directory. https://jsoneditoronline.org/
This is a example of a site which can create JSON file online.

How to configure PhpStorm to use LESS

I would start to use LESS so I try to configure my PhpStorm v8.0.3 to automatically compile .less into .css files.
I have installed node.js and installed less ( npm install -g less ), then I tried to set IDE but I obtained errors.
In Program input I don't know what write, if I leave empty the program say
"Please set program to run!"
If I use a macro the most of time I obtain error permissions
"error = 13"
You need less plugin for phpstorm https://plugins.jetbrains.com/plugin/7059?pr=idea after install restart phpstorm and open .less file
Phpstorm suggest you to add File Watcher for compiling less files automatically.
You need to point your Program field to your lessc file (lessc.cmd on Windows).
Here is what I'm using on Windows:
P.S.
I'm keeping my .less files in /assets/less/ folder and compiled files in /assets/css/ -- hence the ../css/ part in file output paths. If you want to keep compiled files next to sources .. then just remove that part.
https://confluence.jetbrains.com/display/PhpStorm/File+Watchers+in+PhpStorm

File watcher for Cython in Pycharm

Cython's *.pyx files need to be compiled for it to function with other py files. Because of this, I would like a file watcher for PyCharm just like for *.coffee files and for *.ts files.
How would one create a file watcher for Cython in Pycharm. A step by step tutorial would be greatly appreciated.
The easiest way would be "Compile on Save".
As an example, in Netbeans the "Compile on Save" feature can be enabled via "Build -> Compiling"
As for the python-demon itself, you could start it by using gunicorn, store md5 hash for each file, revalidate them all the time, and rebuild as soon as hash key was changed for the file.