An open API service indexing awesome lists of open source software.

https://github.com/cnpm/nodeinstall

Another node installer that bundle node with application.
https://github.com/cnpm/nodeinstall

Last synced: about 1 year ago
JSON representation

Another node installer that bundle node with application.

Awesome Lists containing this project

README

          

# Nodeinstall

[![NPM version][npm-image]][npm-url]
[![Node.js CI](https://github.com/cnpm/nodeinstall/actions/workflows/nodejs.yml/badge.svg)](https://github.com/cnpm/nodeinstall/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/nodeinstall.svg?style=flat-square
[npm-url]: https://npmjs.org/package/nodeinstall
[codecov-image]: https://codecov.io/gh/cnpm/nodeinstall/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/cnpm/nodeinstall
[download-image]: https://img.shields.io/npm/dm/nodeinstall.svg?style=flat-square
[download-url]: https://npmjs.org/package/nodeinstall

Another node installer that bundle node with application.

## Why

Nodeinstall is not a node version switcher, it will install node locally(in node_modules). Then you can deploy application everywhere without Node installed.

You can start application with `npm start` easily, npm will find node from `$PWD/node_modules/.bin/node`

Nodeinstall let application use the same node version in every environment(local development for production).

## Installation

```shell
$ npm install nodeinstall -g
```

## Feature

- ✔︎ Install Node to Local
- ✔︎ Support [Alinode] and [NSolid]
- ✔︎ Support RC and nighly
- ✔︎ Package Define
- ✔︎ Ignore Unsafe Versions

## Usage

Install node to node_modules

```shell
$ nodeinstall 6.0.0
$ ./node_modules/.bin/node -v
```

You can use semver range to match the real version

```shell
$ nodeinstall ^6.0.0
$ ./node_modules/.bin/node -v
```

You can also use nodeinstall to install [Alinode] or [NSolid]

```shell
$ nodeinstall --install-alinode 1.6.0
$ ./node_modules/.bin/node -p 'process.versions.alinode'
$ nodeinstall --install-nsolid 1.6.0
$ ./node_modules/.bin/node -p 'process.versions.nsolid'
```

You can define version in package.json

```json
{
"engines": {
"install-node": "^18.0.0"
}
}
```

Also support

- `install-alinode` for [Alinode]
- `install-nsolid` for [NSolid]
- `install-noderc`
- `install-nightly`

**If you are in China, you can use `--china` flag to speed up.**

## API

```js
const install = require('nodeinstall').install;
await install({
version: '^18.0.0',
});
```

### Options

#### cwd

The current directory, default is `process.cwd`.

#### version

The version that you want to install, it also can be semver range that get the right version automatically.

Version matching is based on distUrl.

#### distUrl

The url where to donwload the tarball, You can find all distUrl in [config.js](https://github.com/cnpm/nodeinstall/blob/master/lib/config.js).

#### china

Use the mirror distUrl in china for speed.

#### cache

#### unsafeVersions

The Map contains the unsafe version and the safe version.

For example, if you install 4.0.0 that is defined in unsafeVersions as an unsafe version, it will install 4.5.0 instead.

```
const unsafeVersions = {
'>= 1.0.0 < 4.4.4': '4.5.0',
};
```

#### installNode

Install Node, it's a default options. Ignore when package define matched..

#### installNoderc

Install Node RC, ignore when package define matched.

#### installAlinode

Install Alinode, ignore when package define matched.

#### installNsolid

Install NSolid, ignore when package define matched.

#### installNightly

Install Node nightly, always be the latest version, ignore when package define matched.

## Questions & Suggestions

Please open an issue [here](https://github.com/eggjs/egg/issues).

## Lisence

MIT

## Contributors

|[
popomore](https://github.com/popomore)
|[
fengmk2](https://github.com/fengmk2)
|[
gemwuu](https://github.com/gemwuu)
|[
richardo2016](https://github.com/richardo2016)
|[
brucewar](https://github.com/brucewar)
|[
lceric](https://github.com/lceric)
|
| :---: | :---: | :---: | :---: | :---: | :---: |

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Dec 10 2022 01:18:52 GMT+0800`.

[Alinode]: https://www.aliyun.com/product/nodejs
[NSolid]: https://nodesource.com/products/nsolid/