build(deps-dev): bump neostandard from 0.12.2 to 0.13.0 (#3289)
Bumps neostandard from 0.12.2 to 0.13.0.
updated-dependencies:
- dependency-name: neostandard dependency-version: 0.13.0 dependency-type: direct:development update-type: version-update:semver-minor …
Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
node-gyp- Node.js native addon build toolnode-gypis a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It contains a vendored copy of the gyp-next project that was previously used by the Chromium team and extended to support the development of Node.js native addons.Note that
node-gypis not used to build Node.js itself.All current and LTS target versions of Node.js are supported. Depending on what version of Node.js is actually installed on your system
node-gypdownloads the necessary development files or headers for the target version. List of stable Node.js versions can be found on Node.js website.Features
Installation
You can install
node-gypusingnpm:Depending on your operating system, you will need to install:
On Unix
makeOn macOS
Xcode Command Line Toolswhich will installclang,clang++, andmake.Xcode Command Line Toolsstandalone by runningxcode-select --install. – OR –Xcode -> Open Developer Tool -> More Developer Tools....On Windows
Install tools with Chocolatey:
Or install and configure Python and Visual Studio tools manually:
Follow the instructions in Using Python on Windows to install the current version of Python.
Install Visual C++ Build Environment: For Visual Studio 2019 or later, use the
Desktop development with C++workload from Visual Studio Community. For a version older than Visual Studio 2019, install Visual Studio Build Tools with theVisual C++ build toolsoption.To target native ARM64 Node.js on Windows on ARM, add the components “Visual C++ compilers and libraries for ARM64” and “Visual C++ ATL for ARM64”.
To use the native ARM64 C++ compiler on Windows on ARM, ensure that you have Visual Studio 2022 17.4 or later installed.
It’s advised to install the following PowerShell module: VSSetup using
Install-Module VSSetup -Scope CurrentUser. This will make Visual Studio detection logic use a more flexible and accessible method, avoiding PowerShell’sConstrainedLanguagemode.Configuring Python Dependency
node-gyprequires that you have installed a supported version of Python. If you have multiple versions of Python installed, you can identify which versionnode-gypshould use in one of the following ways:--pythoncommand-line option, e.g.:If
node-gypis called by way ofnpm, and you have multiple versions of Python installed, then you can set thenpm_config_pythonenvironment variable to the appropriate path:Or on Windows:
If the
PYTHONenvironment variable is set to the path of a Python executable, then that version will be used if it is a supported version.If the
NODE_GYP_FORCE_PYTHONenvironment variable is set to the path of a Python executable, it will be used instead of any of the other configured or built-in Python search paths. If it’s not a compatible version, no further searching will be done.Build for Third Party Node.js Runtimes
When building modules for third-party Node.js runtimes like Electron, which have different build configurations from the official Node.js distribution, you should use
--dist-urlor--nodedirflags to specify the headers of the runtime to build for.Also when
--dist-urlor--nodedirflags are passed, node-gyp will use theconfig.gypishipped in the headers distribution to generate build configurations, which is different from the default mode that would use theprocess.configobject of the running Node.js instance.Some old versions of Electron shipped malformed
config.gypiin their headers distributions, and you might need to pass--force-process-configto node-gyp to work around configuration errors.How to Use
To compile your native addon first go to its root directory:
The next step is to generate the appropriate project build files for the current platform. Use
configurefor that:Auto-detection fails for Visual C++ Build Tools 2015, so
--msvs_version=2015needs to be added (not needed when run by npm as configured above):Note: The
configurestep looks for abinding.gypfile in the current directory to process. See below for instructions on creating abinding.gypfile.Now you will have either a
Makefile(on Unix platforms) or avcxprojfile (on Windows) in thebuild/directory. Next, invoke thebuildcommand:Now you have your compiled
.nodebindings file! The compiled bindings end up inbuild/Debug/orbuild/Release/, depending on the build mode. At this point, you can require the.nodefile with Node.js and run your tests!Note: To create a Debug build of the bindings file, pass the
--debug(or-d) switch when running either theconfigure,buildorrebuildcommands.The
binding.gypfileA
binding.gypfile describes the configuration to build your module, in a JSON-like format. This file gets placed in the root of your package, alongsidepackage.json.A barebones
gypfile appropriate for building a Node.js addon could look like:Further reading
The docs directory contains additional documentation on specific node-gyp topics that may be useful if you are experiencing problems installing or building addons using node-gyp.
Some additional resources for Node.js native addons and writing
gypconfiguration files:Commands
node-gypresponds to the following commands:helpbuildmake/msbuild.exeand builds the native addoncleanbuilddirectory if it existsconfigurerebuildclean,configureandbuildall in a rowinstalllistremoveCommand Options
node-gypaccepts the following command options:-j n,--jobs nmakein parallel. The valuemaxwill use all available CPU cores--target=v6.2.1process.version)--silly,--loglevel=silly--verbose,--loglevel=verbose--silent,--loglevel=silentdebug,--debugRelease)--release,--no-debug-C $dir,--directory=$dir--make=$makemakecommand (e.g.gmake)--thin=yes--arch=$arch--tarball=$path--devdir=$path--ensure--dist-url=$url--proxy=$url--noproxy=$urls--cafile=$cafile--nodedir=$path--python=$path--msvs_version=$version--solution=$solution--force-process-configprocess.configobject to generateconfig.gypifileConfiguration
package.json
Use the
configobject in your package.json with each key in the formnode_gyp_OPTION_NAME. Any of the command options listed above can be set (dashes in option names should be replaced by underscores).For example, to set
devdirequal to/tmp/.gyp, your package.json would contain this:Environment variables
Use the form
npm_package_config_node_gyp_OPTION_NAMEfor any of the command options listed above (dashes in option names should be replaced by underscores).For example, to set
devdirequal to/tmp/.gyp, you would:Run this on Unix:
Or this on Windows:
Note that in versions of npm before v11 it was possible to use the prefix
npm_config_for environment variables. This was deprecated in npm@11 and will be removed in npm@12 so it is recommended to convert your environment variables to the above format.npmconfiguration for npm versions before v9Use the form
OPTION_NAMEfor any of the command options listed above.For example, to set
devdirequal to/tmp/.gyp, you would run:Note: Configuration set via
npmwill only be used whennode-gypis run vianpm, not whennode-gypis run directly.License
node-gypis available under the MIT license. See the LICENSE file for details.