Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build 32-bit binaries on a 64-bit system using npm?

I'm developing an application that I plan to distribute using node-webkit, which only has 32-bit binaries on Windows. My OS is Windows 7 Ultimate 64-bit, so npm is building 64-bit binaries of protobuf for node, which is a prerequisite of one of the modules I am using.

I have tried:

  • npm install protobuf --arch=ia32
  • npm install protobuf --target_arch=ia32
  • npm set npm_config_arch ia32
  • Installing the 32-bit version of node and npm and using it to install protobuf

And a few other things that I can't remember at the moment.

How can I get npm to build 32-bit binaries? Would I have to build it on a 32-bit machine?

like image 838
Dr. McKay Avatar asked Mar 17 '14 07:03

Dr. McKay


People also ask

Where does npm install global binaries?

Path of Global Packages in the system: Global modules are installed in the standard system in root location in system directory /usr/local/lib/node_modules project directory. Command to print the location on your system where all the global modules are installed.

What is Prebuild in npm?

By "prebuilt", that means you won't have to build the C++ code yourself. It is pre-built (== built in advance) by the node-printer package. Follow this answer to receive notifications. answered Dec 27, 2019 at 5:56.

Where are npm binaries?

When executables are installed via npm packages, npm links to them: In local installs, they are linked to from a node_modules/. bin/ directory. In global installs, they are linked to from a global bin/ directory (e.g. /usr/local/bin ).


2 Answers

You should be able to clone the repo into node_modules yourself and compile it manually using

node-gyp clean configure build --verbose --arch=ia32

inside the directory where you cloned the repo.

like image 193
asherkin Avatar answered Oct 13 '22 01:10

asherkin


Add a file in your project root called .npmrc Windows explorer doesn't allow creation of a file name starting with a dot, but this can be done on windows command line like this:

type NUL > .npmrc

Then add the following line to the file:

npm_config_arch=ia32

You may also want to put this line in there to force VS build version, since some packages want to use non-installed versions. Replace 2013 with your version of Visual Studio if different (2012, etc):

msvs_version=2013
like image 29
Derrick Avatar answered Oct 13 '22 03:10

Derrick