Unable to install grpc binaries - node.js

I am trying to run a Node.js app on Azure.
To do that, I need to download all node_modules on my local machine, then copy all of them (along with my app) into Azure.
One of the packages in the project is grpc. During the installation, it creates a binary file on my local machine named node-v57-win32-x64\grpc_node.node.
When I try to run the app on Azure it crashes because it can't find a file called node-v46-win32-ia32\grpc_node.node.
As you can see, there are two differences in those filenames.
I couldn't figure out what v46 and v57 stands for. Also, how do I build it for ia32 while I'm on an x64 machine?

In that filename, the "v57" and "v46" refer to Node internal version numbers that match up with Node major versions (for the most part). In this particular case, "v46" corresponds to Node 4.x, and "v57" corresponds to Node 8.x. So, you should be able to force the installation of that binary by installing with the following command:
npm install --target=4.0.0 --target_arch=ia32

Related

Different node version for different projects, is there a way of telling node which version to use?

I have a pretty common (i guess) problem. Many of my projects utilize nodejs, some for business logic, others only for some building task.
I need to have different runtimes in different projects, one of my electron apps requires node 7.10.0, a typical build suite requires node 8.x.
Now i know - i can use sudo n 7.10.0 or sudo n latest to switch the runtime globally on my computer (For those, who dont know this - have a look at "n")
Anyway, IMO this is not so convenient (some times, i need to rebuild all the modules after switching versions, often i forget to switch and so on). Is there a way of telling node which interpreter to use? Can i use a .npmrc file in a project directory to force a specific nodejs version within that subdirectory?
I searched exactly for this (npmrc node version) but was not lucky enough to find something.
Okay, i found a similar quesion:
Automatically switch to correct version of Node based on project
it seems you can install "avn" and use a .node-version file to do exactly that.
sudo npm install -g avn avn-n
avn setup
then you can create a .node-version file in your project and enter the desired version
echo 7.10.0 > .node-version
Then avn will detect that and activate the correct version
Unfortunately i get an additional permissions error. So to make this work, you need to install/configure "n" to work without sudo/root.
If you're fine with using another tool you could use nvshim.
pip install nvshim # this is all you need to do
It does not slow your shell startup or switching directories, instead moving the lookup of which node version to when you call node, npm or npx by shimming those binaries. More details in the docs.
Source, I wrote the tool.
NVM (Node Version Manager) allow us to use different versions of node quite easily on a single machine. You can have a look at here how to configure and use it.
Volta can used to manage multiple nodejs, npm or yarn versions on different projects on same machine. It's cross-platform.
For example you can run volta pin node#14 in project directory and this will set node to v14 if it exists otherwise it will download and then set it.
More information here https://docs.volta.sh/guide/

npm install issue with meteor custom deployment

I have used meteor build command to create a deployment bundle .tar.gz which is plain Node.js application.
I extract bundle and run following command to run app:
cd programs/server && npm install
But i am not available to run npm install, it is returning message 'SampleApplication module is not defined' and 'sampleapplication' is name of my application.
Given the error you posted, and the limited information available, I assume you're experiencing capitalization sensitivity from whatever OS your deployment server is on. Windows, Linux, OSX all handle capitalization in file paths differently.
Thus, if you develop on OSX which does not care about capitalization and deploy to a windows server which treats file paths as is you can run into issues with required file paths in your program if you are not careful.

Easy Install of Node js package on without publishing

I am looking for a way to deploy a node js app to multiple machines locally.
Is there some way to create a batch file to zip, or installer file, that will put my node js application and all its dependencies, and possibly get node js too easily on multiple machines by sending one or more files to install?
Also, is there some way to provide updates if the code is updated to all these machines?
Basically, I want to be able to install my node js package/application on multiple locations locally without having to publish my work to npm. Any ideas? cant seem to find anything out there except for putting node js on a web server, or publishing to npm?
This is quite vast. Without using advanced tools these two could work :
git pull origin master
npm install
or a solution with rsync
node js application and all its dependencies
Run an npm install where you're developing your application. Then, just tarball the whole thing, including the node_modules directory. When you deploy your tarball to another machine, be sure to run npm rebuild so that any binary dependencies are built for the platform you just deployed to. If you do your initial npm install on the same platform type, you can usually skip the rebuild step.
Also, is there some way to provide updates if the code is updated to all these machines?
There are an infinite number of ways, and what you pick depends on your needs. You could check-in your whole project including node_modules to version control and just have a Bash script regularly pull from a branch and bounce things as necessary for your specific needs. Beware though that node_modules tends to be huge... it's usually left out of version control. Perhaps stick to the tarball on a server and pull that as necessary.
and possibly get node js too
Keep that separate. You don't need to deploy Node.js every time you deploy your application.

Running gulp on project fails because it cannot find an existing file

I'm currently porting a fully working Windows project to an Ubuntu system. After doing the installation of apache/php/mysql/composer/nodejs/nmp I try to run the project. I got the directory where the sources are located (in the web servers location) and I do composer install and the nmp install and they all finish without a flaw. The last step is to call gulp. When I do, I get several of the following errors:
gulp-notify: [Laravel Elixir] Browserify Failed!: Cannot find module
'./components/Colegiados/pagosMatricula/index.vue' from
'/home/web/martilleros/resources/src'
However, the files are there at the specified location. So what am I doing wrong?

Compiled node.js module not getting correct library path when copied to different machines

My problem is a little complicated but I'll try:
I have a node.js application that needs to be completely prebuilt and bundled alongside standalone node.js (specifically 4.4.5 LTS), zipped and deployed to offline CentOS 6/7 machines, meaning I cannot do npm install, and no gcc/g++/python so I cannot do things like node-gyp rebuild.
Everything is working correctly except this module: ibm_db.
It's compiled with node-gyp after downloading the db2 cli drivers, but basically it's supposed to work like the regular DB2 client except all its dynamic libraries, binaries etc. are inside the module path itself (node_modules/ibm_db/installer/clidriver).
If I deploy the bundle (which includes all node modules in the tarball, including ibm_db) to another machine, it's probably going to sit on a different path from the machine on which I built the bundle. When I try to run the app like this: ./node app.js (here node is a symlink to the standalone node binary inside the unpacked bundle) i get this error:
Error: libdb2.so.1: cannot open shared object file: No such file or directory
Now, I can clearly see that libdb2.so.1 is inside node_modules/ibm_db/installer/clidriver/lib but the paths in bindings.gyp all use the original paths on the build machine which don't match, so I assume this is where the problem lies.
I can easily just add that path with ldconfig and it would work, however the user profile installing the app will not have superuser access so it's not a real option.
I tried setting the environment variable LD_LIBRARY_PATH but node.js deletes this entry from process.env on startup, and even if I programmatically set it like process.env.LD_LIBRARY_PATH='...'; it doesn't seem to do anything.
Is there any way to modify the library path for a compiled module without recompiling/rebuilding it? If it's possible I would assume that would be the easiest solution, but I couldn't find a way to do it.

Resources