Node-Pre-Gyp Warn Using Needle For Node-Pre-Gyp Https Download UPDATED

Node-Pre-Gyp Warn Using Needle For Node-Pre-Gyp Https Download

node-pre-gyp

node-pre-gyp makes information technology easy to publish and install Node.js C++ addons from binaries

Build Status Build status

node-pre-gyp stands betwixt npm and node-gyp and offers a cross-platform method of binary deployment.

Features

  • A control line tool called node-pre-gyp that can install your package's C++ module from a binary.
  • A variety of developer targeted commands for packaging, testing, and publishing binaries.
  • A JavaScript module that tin dynamically require your installed binary: require('node-pre-gyp').observe

For a hullo world example of a module packaged with node-pre-gyp see https://github.com/springmeyer/node-addon-case and the wiki for real earth examples.

Credits

  • The module is modeled after node-gyp by @Tootallnate
  • Motivation for initial development came from @ErisDS and the Ghost Project.
  • Evolution is sponsored by Mapbox

FAQ

See the Ofttimes Ask Questions.

Depends

  • Node.js >= node v6.x

Install

node-pre-gyp is designed to be installed as a local dependency of your Node.js C++ addon and accessed similar:

              ./node_modules/.bin/node-pre-gyp --assist                          

Simply you can also install it globally:

              npm install node-pre-gyp -k                          

Usage

Commands

View all possible commands:

              node-pre-gyp --assist                          
  • clean - Remove the entire binder containing the compiled .node module
  • install - Install pre-built binary for module
  • reinstall - Run "make clean" and "install" at one time
  • build - Compile the module by dispatching to node-gyp or nw-gyp
  • rebuild - Run "clean" and "build" at one time
  • package - Pack binary into tarball
  • testpackage - Exam that the staged package is valid
  • publish - Publish pre-built binary
  • unpublish - Unpublish pre-built binary
  • info - Fetch info on published binaries

Y'all can also chain commands:

              node-pre-gyp clean build unpublish publish info                          

Options

Options include:

  • -C/--directory: run the command in this directory
  • --build-from-source: build from source instead of using pre-built binary
  • --update-binary: reinstall by replacing previously installed local binary with remote binary
  • --runtime=node-webkit: customize the runtime: node, electron and node-webkit are the valid options
  • --fallback-to-build: fallback to edifice from source if pre-built binary is not available
  • --target=0.4.0: Laissez passer the target node or node-webkit version to compile against
  • --target_arch=ia32: Pass the target arch and override the host arch. Valid values are 'ia32','x64', or arm.
  • --target_platform=win32: Pass the target platform and override the host platform. Valid values are linux, darwin, win32, sunos, freebsd, openbsd, and aix.

Both --build-from-source and --fallback-to-build tin can exist passed alone or they can provide values. You can pass --fallback-to-build=imitation to override the pick equally declared in bundle.json. In addition to being able to pass --build-from-source you tin can likewise laissez passer --build-from-source=myapp where myapp is the name of your module.

For instance: npm install --build-from-source=myapp. This is useful if:

  • myapp is referenced in the package.json of a larger app and therefore myapp is being installed as a dependency with npm install.
  • The larger app likewise depends on other modules installed with node-pre-gyp
  • You only desire to trigger a source compile for myapp and the other modules.

Configuring

This is a guide to configuring your module to use node-pre-gyp.

ane) Add new entries to your parcel.json

  • Add together node-pre-gyp to dependencies
  • Add aws-sdk equally a devDependency
  • Add together a custom install script
  • Declare a binary object

This looks similar:

                "dependencies"                :                {                "node-pre-gyp":                "0.half dozen.10"                }                ,                "devDependencies":                {                "aws-sdk":                "2.ten"                }                "scripts":                {                "install":                "node-pre-gyp install --fallback-to-build"                }                ,                "binary":                {                "module_name":                "your_module"                ,                "module_path":                "./lib/binding/"                ,                "host":                "https://your_module.s3-u.s.a.-west-1.amazonaws.com"                }              

For a full case meet node-addon-examples's package.json.

Let's break this down:

  • Dependencies need to listing node-pre-gyp
  • Your devDependencies should listing aws-sdk then that y'all can run node-pre-gyp publish locally or a CI organization. We recommend using devDependencies only since aws-sdk is large and not needed for node-pre-gyp install since it only uses http to fetch binaries
  • Your scripts section should override the install target with "install": "node-pre-gyp install --fallback-to-build". This allows node-pre-gyp to be used instead of the default npm beliefs of always source compiling with node-gyp direct.
  • Your package.json should contain a binary section describing key backdrop yous provide to let node-pre-gyp to package optimally. They are detailed below.

Note: in the past we recommended putting node-pre-gyp in the bundledDependencies, merely nosotros no longer recommend this. In the past there were npm bugs (with node versions 0.10.x) that could lead to node-pre-gyp not being available at the right time during install (unless nosotros bundled). This should no longer be the case. Too, for a time we recommended using "preinstall": "npm install node-pre-gyp" as an culling method to avoid needing to packet. Only this did not bear predictably across all npm versions - see https://github.com/mapbox/node-pre-gyp/issues/260 for the details. So we exercise not recommend using preinstall to install node-pre-gyp. More history on this at https://github.com/strongloop/fsevents/issues/157#issuecomment-265545908.

The binary object has 3 required properties
module_name

The name of your native node module. This value must:

  • Match the proper noun passed to the NODE_MODULE macro
  • Must be a valid C variable name (due east.one thousand. it cannot incorporate -)
  • Should not include the .node extension.
module_path

The location your native module is placed after a build. This should be an empty directory without other Javascript files. This entire directory will be packaged in the binary tarball. When installing from a remote package this directory will be overwritten with the contents of the tarball.

Notation: This belongings supports variables based on Versioning.

host

A url to the remote location where you've published tarball binaries (must be https not http).

It is highly recommended that you use Amazon S3. The reasons are:

  • Various node-pre-gyp commands like publish and info only piece of work with an S3 host.
  • S3 is a very solid hosting platform for distributing large files.
  • We provide detail documentation for using S3 hosting with node-pre-gyp.

Why so not crave S3? Because while some applications using node-pre-gyp need to distribute binaries equally large equally 20-thirty MB, others might have very pocket-sized binaries and might wish to store them in a GitHub repo. This is not recommended, but if an author really wants to host in a non-S3 location and so it should be possible.

It should also be mentioned that there is an optional and entirely split up npm module called node-pre-gyp-github which is intended to complement node-pre-gyp and be installed along with it. It provides the ability to shop and publish your binaries within your repositories GitHub Releases if you would rather not use S3 directly. Installation and usage instructions can exist institute here, simply the basic premise is that instead of using the node-pre-gyp publish command you lot would use node-pre-gyp-github publish.

The binary object has two optional properties
remote_path

Information technology is recommended that you lot customize this property. This is an extra path to employ for publishing and finding remote tarballs. The default value for remote_path is "" meaning that if you lot do not provide it then all packages will be published at the base of operations of the host. It is recommended to provide a value like ./{name}/v{version} to help organize remote packages in the instance that you choose to publish multiple node addons to the same host.

Note: This property supports variables based on Versioning.

package_name

Information technology is not recommended to override this holding unless you lot are also overriding the remote_path. This is the versioned name of the remote tarball containing the binary .node module and any supporting files you've placed inside the module_path directory. Unless you specify package_name in your package.json and then it defaults to {module_name}-five{version}-{node_abi}-{platform}-{arch}.tar.gz which allows your binary to work beyond node versions, platforms, and architectures. If you are using remote_path that is besides versioned by ./{module_name}/v{version} and then you could remove these variables from the package_name and but utilise: {node_abi}-{platform}-{arch}.tar.gz. Then your remote tarball will exist looked up at, for instance, https://example.com/your-module/v0.one.0/node-v11-linux-x64.tar.gz.

Avoiding the version of your module in the package_name and instead only embedding in a directory proper name tin be useful when you want to make a quick tag of your module that does not modify any C++ lawmaking. In this instance you can just re-create binaries to the new version backside the scenes like:

aws s3 sync --acl public-read s3://mapbox-node-binary/sqlite3/v3.0.3/ s3://mapbox-node-binary/sqlite3/v3.0.4/

Note: This holding supports variables based on Versioning.

2) Add a new target to binding.gyp

node-pre-gyp calls out to node-gyp to compile the module and passes variables forth like module_name and module_path.

A new target must be added to binding.gyp that moves the compiled .node module from ./build/Release/module_name.node into the directory specified by module_path.

Add a target like this at the cease of your targets list:

                {                "target_name":                "action_after_build"                ,                "type":                "none"                ,                "dependencies":                [                "<(module_name)"                ]                ,                "copies":                [                {                "files":                [                "<(PRODUCT_DIR)/<(module_name).node"                ]                ,                "destination":                "<(module_path)"                }                ]                }              

For a full example see node-addon-example'south bounden.gyp.

3) Dynamically require your .node

Inside the master js file that requires your addon module you lot are likely currently doing:

                var                binding                =                crave                (                '../build/Release/binding.node'                )                ;              

or:

                var                bindings                =                require                (                './bindings'                )              

Change those lines to:

                var                binary                =                require                (                'node-pre-gyp'                )                ;                var                path                =                require                (                'path'                )                ;                var                binding_path                =                binary                .                find                (                path                .                resolve                (                path                .                join                (                __dirname                ,                './package.json'                )                )                )                ;                var                binding                =                crave                (                binding_path                )                ;              

For a total case see node-addon-example's index.js

4) Build and parcel your app

Now build your module from source:

              npm install --build-from-source                          

The --build-from-source tells node-pre-gyp to not wait for a remote bundle and instead dispatch to node-gyp to build.

Now node-pre-gyp should at present also be installed as a local dependency so the command line tool information technology offers tin can be found at ./node_modules/.bin/node-pre-gyp.

5) Examination

Now npm test should work just every bit information technology did before.

half dozen) Publish the tarball

And then package your app:

              ./node_modules/.bin/node-pre-gyp package                          

Once packaged, at present yous can publish:

              ./node_modules/.bin/node-pre-gyp publish                          

Currently the publish command pushes your binary to S3. This requires:

  • You lot take installed aws-sdk with npm install aws-sdk
  • Y'all accept created a bucket already.
  • The host points to an S3 http or https endpoint.
  • You have configured node-pre-gyp to read your S3 credentials (see S3 hosting for details).

You can likewise host your binaries elsewhere. To practise this requires:

  • You manually publish the binary created by the package command to an https endpoint
  • Ensure that the host value points to your custom https endpoint.

7) Automate builds

At present you demand to publish builds for all the platforms and node versions yous wish to support. This is best automated.

  • Run across Appveyor Automation for how to automobile-publish builds on Windows.
  • See Travis Automation for how to auto-publish builds on OS X and Linux.

viii) You're done!

Now publish your module to the npm registry. Users will now exist able to install your module from a binary.

What will happen is this:

  1. npm install <your bundle> will pull from the npm registry
  2. npm will run the install script which will call out to node-pre-gyp
  3. node-pre-gyp volition fetch the binary .node module and unpack in the right place
  4. Assuming that all worked, you are done

If a a binary was not available for a given platform and --fallback-to-build was used so node-gyp rebuild will be chosen to endeavor to source compile the module.

Due north-API Considerations

Northward-API is an ABI-stable alternative to previous technologies such as nan which are tied to a specific Node runtime engine. N-API is Node runtime engine doubter and guarantees modules created today will continue to run, without changes, into the future.

Using node-pre-gyp with Northward-API projects requires a handful of additional configuration values and imposes some boosted requirements.

The well-nigh meaning difference is that an N-API module tin exist coded to target multiple North-API versions. Therefore, an N-API module must declare in its package.json file which N-API versions the module is designed to run confronting. In addition, since multiple builds may be required for a single module, path and file names must be specified in fashion that avoids naming conflicts.

The napi_versions array property

An N-API modules must declare in its parcel.json file, the N-API versions the module is intended to support. This is accomplished by including an napi-versions array property in the binary object. For instance:

                "binary":                {                "module_name":                "your_module"                ,                "module_path":                "your_module_path"                ,                "host":                "https://your_bucket.s3-us-w-ane.amazonaws.com"                ,                "napi_versions":                [                1                ,                3                ]                }              

If the napi_versions array property is not present, node-pre-gyp operates as it always has. Including the napi_versions array holding instructs node-pre-gyp that this is a Due north-API module build.

When the napi_versions array belongings is present, node-pre-gyp fires off multiple operations, one for each of the Northward-API versions in the assortment. In the instance above, ii operations are initiated, one for North-API version i and second for N-API version 3. How this version number is communicated is described adjacent.

The napi_build_version value

For each of the N-API module operations node-pre-gyp initiates, it ensures that the napi_build_version is set appropriately.

This value is of importance in 2 areas:

  1. The C/C++ code which needs to know against which Northward-API version it should compile.
  2. node-pre-gyp itself which must assign appropriate path and file names to avoid collisions.

Defining NAPI_VERSION for the C/C++ code

The napi_build_version value is communicated to the C/C++ code by adding this code to the binding.gyp file:

              "defines": [     "NAPI_VERSION=<(napi_build_version)", ]                          

This ensures that NAPI_VERSION, an integer value, is declared appropriately to the C/C++ lawmaking for each build.

Annotation that earlier versions of this document recommended defining the symbol NAPI_BUILD_VERSION. NAPI_VERSION is prefered considering information technology used by the N-API C/C++ headers to configure the specific North-API veriosn being requested.

Path and file naming requirements in package.json

Since node-pre-gyp fires off multiple operations for each request, it is essential that path and file names be created in such a way as to avoid collisions. This is achieved past imposing additional path and file naming requirements.

Specifically, when performing North-API builds, the {napi_build_version} text configuration value must exist present in the module_path property. In improver, the {napi_build_version} text configuration value must be nowadays in either the remote_path or package_name holding. (No problem if it's in both.)

Here'due south an instance:

                "binary":                {                "module_name":                "your_module"                ,                "module_path":                "./lib/binding/napi-v{napi_build_version}"                ,                "remote_path":                "./{module_name}/v{version}/{configuration}/"                ,                "package_name":                "{platform}-{arch}-napi-v{napi_build_version}.tar.gz"                ,                "host":                "https://your_bucket.s3-united states-west-1.amazonaws.com"                ,                "napi_versions":                [                ane                ,                3                ]                }              

Supporting both North-API and NAN builds

You may have a legacy native add-on that you wish to continue supporting for those versions of Node that do not back up N-API, as you add N-API support for later Node versions. This tin exist accomplished by specifying the node_napi_label configuration value in the bundle.json binary.package_name property.

Placing the configuration value node_napi_label in the parcel.json binary.package_name holding instructs node-pre-gyp to build all feasible Northward-API binaries supported by the electric current Node instance. If the current Node instance does not support N-API, node-pre-gyp will request a traditional, non-N-API build.

The configuration value node_napi_label is ready by node-pre-gyp to the type of build created, napi or node, and the version number. For N-API builds, the string contains the North-API version nad has values like napi-v3. For traditional, non-N-API builds, the cord contains the ABI version with values similar node-v46.

Hither's how the binary configuration above might be changed to support both North-API and NAN builds:

                "binary":                {                "module_name":                "your_module"                ,                "module_path":                "./lib/binding/{node_napi_label}"                ,                "remote_path":                "./{module_name}/v{version}/{configuration}/"                ,                "package_name":                "{platform}-{arch}-{node_napi_label}.tar.gz"                ,                "host":                "https://your_bucket.s3-us-west-ane.amazonaws.com"                ,                "napi_versions":                [                i                ,                3                ]                }              

The C/C++ symbol NAPI_VERSION can be used to distinguish N-API and not-N-API builds. The value of NAPI_VERSION is set up to the integer N-API version for Due north-API builds and is set to 0 for non-N-API builds.

For example:

#if                NAPI_VERSION                                  //                  North-API lawmaking goes here                #else                                  //                  NAN lawmaking goes here                #endif              

Two additional configuration values

The post-obit two configuration values, which were implemented in previous versions of node-pre-gyp, proceed to exist, simply accept been replaced by the node_napi_label configuration value described above.

  1. napi_version If N-API is supported by the currently executing Node case, this value is the Due north-API version number supported by Node. If North-API is not supported, this value is an empty string.

  2. node_abi_napi If the value returned for napi_version is non empty, this value is 'napi'. If the value returned for napi_version is empty, this value is the value returned for node_abi.

These values are present for use in the bounden.gyp file and may be used as {napi_version} and {node_abi_napi} for text substituion in the binary properties of the package.json file.

S3 Hosting

Yous tin host wherever you choose merely S3 is cheap, node-pre-gyp publish expects it, and S3 can be integrated well with Travis.ci to automate builds for OS X and Ubuntu, and with Appveyor to automate builds for Windows. Here is an arroyo to exercise this:

First, get setup locally and test the workflow:

ane) Create an S3 bucket

And have your key and secret key ready for writing to the saucepan.

It is recommended to create a IAM user with a policy that but gives permissions to the specific saucepan you programme to publish to. This can be done in the IAM panel by: 1) adding a new user, 2) choosing Attach User Policy, 3) Using the Policy Generator, 4) selecting Amazon S3 for the service, 5) adding the actions: DeleteObject, GetObject, GetObjectAcl, ListBucket, PutObject, PutObjectAcl, 6) adding an ARN of arn:aws:s3:::saucepan/* (replacing bucket with your bucket name), and finally vii) clicking Add together Argument and saving the policy. It should generate a policy like:

                {                "Version":                "2012-10-17"                ,                "Statement":                [                {                "Sid":                "Stmt1394587197000"                ,                "Effect":                "Let"                ,                "Activeness":                [                "s3:DeleteObject"                ,                "s3:GetObject"                ,                "s3:GetObjectAcl"                ,                "s3:ListBucket"                ,                "s3:PutObject"                ,                "s3:PutObjectAcl"                ]                ,                "Resource":                [                "arn:aws:s3:::node-pre-gyp-tests/*"                ]                }                ]                }              

ii) Install node-pre-gyp

Either install it globally:

              npm install node-pre-gyp -g                          

Or put the local version on your PATH

              export PATH=`pwd`/node_modules/.bin/:$PATH                          

3) Configure AWS credentials

There are several ways to practice this.

You can utilise any of the methods described at http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html.

Or yous can create a ~/.node_pre_gyprc

Or laissez passer options in any style supported by RC

A ~/.node_pre_gyprc looks like:

                {                "accessKeyId":                "xxx"                ,                "secretAccessKey":                "xxx"                }              

Another way is to use your environment:

              consign node_pre_gyp_accessKeyId=xxx consign node_pre_gyp_secretAccessKey=xxx                          

You may also demand to specify the region if it is not explicit in the host value you use. The saucepan can as well be specified but it is optional considering node-pre-gyp will detect information technology from the host value.

iv) Packet and publish your build

Install the aws-sdk:

              npm install aws-sdk                          

Then publish:

              node-pre-gyp package publish                          

Note: if you hit an error like Hostname/IP doesn't match certificate's altnames information technology may mean that yous demand to provide the region choice in your config.

Appveyor Automation

Appveyor can build binaries and publish the results per commit and supports:

  • Windows Visual Studio 2013 and related compilers
  • Both 64 flake (x64) and 32 scrap (x86) build configurations
  • Multiple Node.js versions

For an example of doing this see node-sqlite3's appveyor.yml.

Below is a guide to getting prepare:

ane) Create a complimentary Appveyor account

Become to https://ci.appveyor.com/signup/free and sign in with your GitHub account.

2) Create a new project

Go to https://ci.appveyor.com/projects/new and select the GitHub repo for your module

3) Add together appveyor.yml and push it

In one case you lot accept committed an appveyor.yml (appveyor.yml reference) to your GitHub repo and pushed it AppVeyor should automatically beginning building your project.

iv) Create secure variables

Encrypt your S3 AWS keys by going to https://ci.appveyor.com/tools/encrypt and striking the encrypt button.

Then paste the result into your appveyor.yml

                environment:                node_pre_gyp_accessKeyId:                secure:                Dn9HKdLNYvDgPdQOzRq/DqZ/MPhjknRHB1o+/lVU8MA=                node_pre_gyp_secretAccessKey:                secure:                W1rwNoSnOku1r+28gnoufO8UA8iWADmL1LiiwH9IOkIVhDTNGdGPJqAlLjNqwLnL              

NOTE: keys are per account but not per repo (this is divergence than Travis where keys are per repo but non related to the account used to encrypt them).

5) Hook up publishing

Just put node-pre-gyp packet publish in your appveyor.yml after npm install.

6) Publish when you desire

Yous might wish to publish binaries only on a specific commit. To do this you could borrow from the Travis CI thought of commit keywords and add special treatment for commit messages with [publish binary]:

              Prepare CM=%APPVEYOR_REPO_COMMIT_MESSAGE% if not "%CM%" == "%CM:[publish binary]=%" node-pre-gyp --msvs_version=2013 publish                          

If your commit message contains special characters (e.thousand. &) this method might fail. An alternative is to employ PowerShell, which gives you boosted possibilities, similar ignoring case past using ToLower():

              ps: if($env:APPVEYOR_REPO_COMMIT_MESSAGE.ToLower().Contains('[publish binary]')) { node-pre-gyp --msvs_version=2013 publish }                          

Remember this publishing is non the aforementioned as npm publish. We're just talking about the binary module here and not your unabridged npm parcel.

Travis Automation

Travis tin push button to S3 after a successful build and supports both:

  • Ubuntu Precise and OS X (64 bit)
  • Multiple Node.js versions

For an example of doing this come across node-add-example'south .travis.yml.

Note: if y'all need 32 bit binaries, this can be done from a 64 scrap Travis automobile. Encounter the node-sqlite3 scripts for an case of doing this.

Beneath is a guide to getting set up:

one) Install the Travis gem

              gem install travis                          

2) Create secure variables

Make certain yous run this command from within the directory of your module.

Use travis-encrypt like:

              travis encrypt node_pre_gyp_accessKeyId=${node_pre_gyp_accessKeyId} travis encrypt node_pre_gyp_secretAccessKey=${node_pre_gyp_secretAccessKey}                          

Then put those values in your .travis.yml like:

                env:                global:     -                secure:                F+sEL/v56CzHqmCSSES4pEyC9NeQlkoR0Gs/ZuZxX1ytrj8SKtp3MKqBj7zhIclSdXBz4Ev966Da5ctmcTd410p0b240MV6BVOkLUtkjZJyErMBOkeb8n8yVfSoeMx8RiIhBmIvEn+rlQq+bSFis61/JkE9rxsjkGRZi14hHr4M=                -                secure:                o2nkUQIiABD139XS6L8pxq3XO5gch27hvm/gOdV+dzNKc/s2KomVPWcOyXNxtJGhtecAkABzaW8KHDDi5QL1kNEFx6BxFVMLO8rjFPsMVaBG9Ks6JiDQkkmrGNcnVdxI/6EKTLHTH5WLsz8+J7caDBzvKbEfTux5EamEhxIWgrI=              

More details on Travis encryption at http://nigh.travis-ci.org/docs/user/encryption-keys/.

iii) Hook up publishing

Just put node-pre-gyp package publish in your .travis.yml after npm install.

OS X publishing

If you want binaries for OS X in add-on to linux you tin can enable multi-os for Travis

Use a configuration like:

                language:                cpp                os: -                linux                -                osx                env:                matrix:     -                NODE_VERSION="iv"                -                NODE_VERSION="six"                before_install: -                rm -rf ~/.nvm/ && git clone --depth ane https://github.com/creationix/nvm.git ~/.nvm                -                source ~/.nvm/nvm.sh                -                nvm install $NODE_VERSION                -                nvm use $NODE_VERSION              

Meet Travis OS X Gotchas for why nosotros replace language: node_js and node_js: sections with language: cpp and a custom matrix.

Also create platform specific sections for any deps that need install. For case if yous need libpng:

-                if [ $(uname -s) == 'Linux' ]; and so apt-go install libpng-dev; fi;                -                if [ $(uname -s) == 'Darwin' ]; then mash install libpng; fi;              

For detailed multi-Os examples see node-mapnik and node-sqlite3.

Travis OS X Gotchas

First, dissimilar the Travis Linux machines, the OS X machines do not put node-pre-gyp on PATH by default. To do so you will need to:

                export                PATH=                  $(pwd)                /node_modules/.bin:${PATH}              

Second, the OS X machines do not support using a matrix for installing different Node.js versions. And so you need to bootstrap the installation of Node.js in a cross platform way.

Past doing:

                env:                matrix:     -                NODE_VERSION="4"                -                NODE_VERSION="half dozen"                before_install:  -                rm -rf ~/.nvm/ && git clone --depth one https://github.com/creationix/nvm.git ~/.nvm                -                source ~/.nvm/nvm.sh                -                nvm install $NODE_VERSION                -                nvm utilise $NODE_VERSION              

Yous tin can hands recreate the previous beliefs of this matrix:

iv) Publish when yous want

You might wish to publish binaries but on a specific commit. To do this you could borrow from the Travis CI thought of commit keywords and add special handling for commit messages with [publish binary]:

              COMMIT_MESSAGE=$(git log --format=%B --no-merges -due north one | tr -d '\north') if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then node-pre-gyp publish; fi;                          

And then you lot can trigger new binaries to exist built like:

              git commit -a -m "[publish binary]"                          

Or, if you lot don't have whatsoever changes to make simply run:

              git commit --allow-empty -chiliad "[publish binary]"                          

WARNING: if y'all are working in a pull request and publishing binaries from there then you volition want to avoid double publishing when Travis CI builds both the button and pr. You only want to run the publish on the push commit. See https://github.com/Project-OSRM/node-osrm/hulk/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/is_pr_merge.sh which is chosen from https://github.com/Projection-OSRM/node-osrm/blob/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/publish.sh for an example of how to do this.

Think this publishing is not the same as npm publish. Nosotros're just talking about the binary module hither and not your unabridged npm package. To automate the publishing of your entire package to npm on Travis see http://almost.travis-ci.org/docs/user/deployment/npm/

Versioning

The binary properties of module_path, remote_path, and package_name back up variable substitution. The strings are evaluated past node-pre-gyp depending on your system and whatsoever custom build flags y'all passed.

  • node_abi: The node C++ ABI number. This value is bachelor in Javascript as process.versions.modules every bit of >= v0.x.4 >= v0.11.seven and in C++ as the NODE_MODULE_VERSION define much earlier. For versions of Node before this was bachelor nosotros fallback to the V8 major and modest version.
  • platform matches node's process.platform like linux, darwin, and win32 unless the user passed the --target_platform option to override.
  • arch matches node's procedure.arch like x64 or ia32 unless the user passes the --target_arch option to override.
  • libc matches require('detect-libc').family unit like glibc or musl unless the user passes the --target_libc option to override.
  • configuration - Either 'Release' or 'Debug' depending on if --debug is passed during the build.
  • module_name - the binary.module_name attribute from package.json.
  • version - the semver version value for your module from package.json (NOTE: ignores the semver.build property).
  • major, minor, patch, and prelease match the individual semver values for your module's version
  • build - the sevmer build value. For instance it would be this.that if your packet.json version was v1.0.0+this.that
  • prerelease - the semver prerelease value. For instance it would be alpha.beta if your package.json version was v1.0.0-alpha.beta

The options are visible in the code at https://github.com/mapbox/node-pre-gyp/blob/612b7bca2604508d881e1187614870ba19a7f0c5/lib/util/versioning.js#L114-L127

Download binary files from a mirror

S3 is broken in Cathay for the well known reason.

Using the npm config argument: --{module_name}_binary_host_mirror can download binary files through a mirror.

e.g.: Install v8-profiler from npm.

$ npm install v8-profiler --profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/

DOWNLOAD HERE

Posted by: dominquezsupprooks72.blogspot.com

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel