Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nw

Package Overview
Dependencies
Maintainers
4
Versions
675
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nw - npm Package Compare versions

Comparing version 0.85.0 to 0.86.0-1-sdk

src/cli.js

34

package.json
{
"name": "nw",
"version": "0.85.0",
"description": "A installer for nw.js",
"version": "0.86.0-1-sdk",
"description": "An installer for nw.js",
"repository": {

@@ -9,14 +9,16 @@ "type": "git",

},
"main": "lib/findpath.js",
"type": "module",
"main": "src/index.js",
"bin": {
"nw": "bin/nw.js"
"nw": "src/cli.js"
},
"scripts": {
"postinstall": "node lib/install.js",
"test": "node --test-reporter=spec --test test/index.js",
"dry-run": "nw ./test/app"
"postinstall": "node src/postinstall.js",
"test": "vitest run",
"demo": "nw ./test/app"
},
"files": [
"bin",
"lib",
"bin"
"src"
],

@@ -35,6 +37,8 @@ "author": {

"dependencies": {
"cli-progress": "^3.12.0",
"compressing": "^1.10.0",
"axios": "^1.6.8",
"commander": "^12.0.0",
"semver": "^7.5.4",
"yargs": "^17.7.2"
"tar": "^6.2.1",
"yargs": "^17.7.2",
"yauzl-promise": "^4.0.0"
},

@@ -52,3 +56,7 @@ "keywords": [

"application"
]
}
],
"devDependencies": {
"selenium-webdriver": "^4.18.1",
"vitest": "^1.4.0"
}
}
# nw
An installer for [NW.js](https://nwjs.io).
An npm installer for [NW.js](https://nwjs.io).
> NW.js is a runtime-environment based on Chromium and Node.js. It is used to build desktop applications that run on Windows, OSX, and Linux.
[![npm](https://img.shields.io/npm/v/nw)](https://www.npmjs.com/package/nw)
[![npm](https://img.shields.io/npm/v/nw.svg?style=flat)](https://www.npmjs.com/package/nw)
## Install
## usage
Install locally to your project with: `npm install nw` and then in your `package.json` add a script:
### Latest version globally
```json
{
"scripts": {
"start": "nw"
}
}
```shell
npm install -g nw
```
Now it will run your local project when you type `npm start`.
You might run into issues installing globally. [Learn how to fix this](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
If your project is in another folder, add the path to the project `"start": "nw path/to/app"`.
### Latest version of normal build flavor:
You could also call `nw` directly from `node_modules/.bin/nw` instead of adding to your `package.json`.
```shell
npm install --save-dev nw
```
### global
You can also install globally with `npm install nw -g` and then in any project type `nw` to run the project. Installing locally is recommended though as each project can have its own dependent version of nw.js.
### Specific version with changes to installer:
## example
If you want a really quick example try this:
```shell
npm install --save-dev nw@0.85.0-1
```
1. `git clone https://github.com/zcbenz/nw-sample-apps && cd nw-sample-apps`
2. `npm init`
3. `npm install nw`
4. `"node_modules/.bin/nw" file-explorer`
> You may use `npm view nw versions` to view the list of available versions.
and now you should see a file explorer demo app.
### Specify build flavor:
## command line options
There are a few (platform-specific) arguments you can pass to the `nw` executable to
customize your nw.js application:
```shell
npm install --save-dev nw@sdk
```
* `--mac_plist <path-to-plist-file>`: (OS X only) Copies the given file to Info.plist in the app
bundle. This lets you do things like change your app's name and point to a different icon.
> Optionally set `nwjs_build_type=sdk` in `.npmrc` or `NWJS_BUILD_TYPE=sdk` environment variable.
* `--mac_icon <path-to-icns-file>`: (OS X only) Copies the given .icns file to the Resources/ dir
in the app bundle. You will need to point to the file with a custom plist file as well (see
`--mac_list`)
### Specify platform:
**NOTE**: These options will keep the copied files in the app bundle for as long as the bundle is
on the filesystem (they're not deleted between app invocations). As a result, they're not
recommended if you installed nw globally using `-g`. Also note that
[OS X caches these files](http://proteo.me.uk/2011/08/mac-application-bundle-caching/),
so you may need to manually clear these cached files during development.
Set `nwjs_platform` in `.npmrc` or `NWJS_PLATFORM` environment variable. Defaults to `process.platform`.
## install a specific version of nw.js
### Specify architecture:
To install a specific version of nw.js use npm with the specific version: `npm install nw@0.12.0`
Set `nwjs_arch` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `process.arch`.
> *Please note:* This npm package version tracks the version of nw.js that will be installed, with an additional build number that is used for revisions to the installer. As such `0.12.0-1` and `0.12.0-2` will both install `nw.js@0.12.0` but the latter has newer changes to the installer.
### Specify cache directory:
You may use `npm view nw versions` to view the list of available versions.
Set `nwjs_cache_dir` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `./node_modules/nw`.
## install a specific build type of nw.js
### Specify cache flag:
nw.js has three build types: `normal`, `sdk` and `nacl`. To install a specific build type you may set npm config property `nwjs_build_type`, environment variable `NWJS_BUILD_TYPE` or pass command line option `--nwjs_build_type`:
Set `nwjs_cache` in `.npmrc` or `NWJS_ARCH` environment variable to keep or delete cached binaries. Defaults to `true`.
``` shell
npm install nw --nwjs_build_type=sdk
```
### Specify ffmpeg flag:
Setting option in `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html):
Set `nwjs_ffmpeg` in `.npmrc` or `NWJS_ARCH` environment variable to toggle downloading [community FFmpeg binaries](https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt). Defaults to `false`.
```
nwjs_build_type=sdk
```
### Specify Native Addon flag:
Setting environment variable `NWJS_BUILD_TYPE`:
Set `nwjs_native_addon` in `.npmrc` or `NWJS_NATIVE_ADDON` environment variable to toggle downloading NW.js Node headers. Defaults to `false`.
``` shell
export NWJS_BUILD_TYPE=sdk
```
### Specify download URL:
You can alternatively install `sdk` build by specifying `-sdk` suffix in version:
Set `nwjs_urlbase` in `.npmrc`or `NWJS_URLBASE` environment variable. Defaults to `https://dl.nwjs.io`. The file system (`file://`) is also supported (for example, `file:///home/localghost/local_mirror`).
``` shell
npm install nw@0.13.3-sdk
```
## Usage
You can also run `npm install nw@sdk` to get the latest of published SDK versions. (Note: that may be a beta version.)
Add a script in your `package.json`:
## install a specific architecture
```json
{
"scripts": {
"start": "nw /path/to/app"
}
}
```
You may use the environment variable `npm_config_nwjs_process_arch` to override the default architecture (`process.arch`) and to download NW.js built for some other architecture.
Executing `npm start` runs the NW.js app. Omitting the file path makes NW.js check for valid project in current working directory. You can also call `nw` directly from `node_modules/.bin/nw`.
## finding the path to the nw.js binary
## APIs
If you would like to programmatically retrieve the path to the nw.js binary use:
### Find path to the NW.js binary:
``` js
var findpath = require('nw').findpath;
var nwpath = findpath();
// nwpath will equal the path to the binary depending on your environment
import { findpath } from 'nw';
var path = findpath();
```
## finding the path to the chromedriver binary
## Find the path to the chromedriver binary
If you would like to programmatically retrieve the path to the chromedriver use:
``` js
var findpath = require('nw').findpath;
var chromedriver_path = findpath('chromedriver');
// chromedriver_path will equal the path to the binary depending on your environment
import { findpath } from 'nw';
var path = findpath('chromedriver');
```
Then you can use that path to run NW.js programmatically. For example, to run in the current script's directory:
## Download specific versions independant of installer version
```js
require('child_process').spawn(
require('nw').findpath(),
['.'].concat( process.argv.slice(2) ),
{
cwd: __dirname,
detached: true,
stdio: 'ignore'
}
).unref();
```
import { get } from 'nw';
## retrieve binaries from custom download location or file path
The installer attempts to download binaries from the default location of `https://dl.nwjs.io/v`. You can override this by setting the npm config property `nwjs_urlbase` on the command line by passing the `--nwjs_urlbase` option:
``` shell
npm install nw --nwjs_urlbase=http://my.own.location/somewhere
await get({
// options
});
```
or adding it to your `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html):
Options:
```
nwjs_urlbase=http://my.own.location/somewhere
```
| Name | Type | Default | Description |
| ---- | ------- | --------- | ----------- |
| version | `string \| "latest" \| "stable"` | `"latest"` | Runtime version |
| flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor |
| platform | `"linux" \| "osx" \| "win"` | | Host platform |
| arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
| downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server |
| cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
| cache | `boolean` | `true`| If true the existing cache is used. Otherwise it removes and redownloads it. |
| ffmpeg | `boolean` | `false`| If true the chromium ffmpeg is replaced by community version with proprietary codecs. |
| nodeAddon | `false \| "gyp"` | `false` | Download Node headers |
You can alternatively set an environment variable `NWJS_URLBASE`:
## License
``` shell
export NWJS_URLBASE=http://my.own.location/somewhere
```
The installer supports `file://` URLs to retrieve files from the local filesystem:
``` shell
export NWJS_URLBASE=file:///home/bilbo/my/own/mirror
```
## using a proxy with or without authentication
If you are behind a proxy server you have to set an environment variable `http_proxy` with proxy servers url:
```
export http_proxy="http://username:password@myproxy.com:8080"
```
or
```
export http_proxy="http://myproxy.com:8080"
```
(However, if the environment variable `https_proxy` is set, then it will be preferred, as [programmed](https://github.com/kevva/get-proxy/blob/master/index.js) in the `get-proxy` package.)
## license
[nw.js](https://github.com/nwjs/nw.js)'s code and this installer use the MIT license.
[NW.js](https://github.com/nwjs/nw.js)'s code and this installer use the MIT license.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc