ehmicky / all-node-versions Goto Github PK
View Code? Open in Web Editor NEWList all available Node.js versions
License: Apache License 2.0
List all available Node.js versions
License: Apache License 2.0
This package uses ES modules. If you're seeing the following error message:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
This means you're using require()
to load this package. An import
or import()
statement should be used instead. For more information, see this blog post.
Following instructions as per the README results in:
SyntaxError: await is only valid in async function
Following the README is enough:
username@hostname MSYS /d
$ mkdir temp
username@hostname MSYS /d
$ cd temp
username@hostname MSYS /d/temp
$ npm install all-node-versions
added 76 packages, and audited 77 packages in 9s
9 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
username@hostname MSYS /d/temp
$ nano all-node-versions.js
And paste:
const allNodeVersions = require('all-node-versions')
const { versions, majors } = await allNodeVersions(options)
console.log(versions)
// ['13.13.0', '13.12.0', ..., '0.1.15', '0.1.14']
console.log(majors)
// [
// { major: 13, latest: '13.13.0' },
// { major: 12, latest: '12.16.2', lts: 'erbium' },
// { major: 11, latest: '11.15.0' },
// { major: 10, latest: '10.20.1', lts: 'dubnium' },
// { major: 9, latest: '9.11.2' },
// { major: 8, latest: '8.17.0', lts: 'carbon' },
// { major: 7, latest: '7.10.1' },
// { major: 6, latest: '6.17.1', lts: 'boron' },
// { major: 5, latest: '5.12.0' },
// { major: 4, latest: '4.9.1', lts: 'argon' },
// { major: 0, latest: '0.12.18' }
// ]
After saving and exiting:
username@hostname MSYS /d/temp
$ node all-node-versions.js
D:\temp\all-node-versions.js:3
const { versions, majors } = await allNodeVersions(options)
^^^^^
SyntaxError: await is only valid in async function
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
I need to use this with typescript, and it doesn't have type definitions
This is what works for me:
declare module "all-node-versions" {
function DefaultFunction(options?: {
mirror?: string;
fetch?: boolean;
}): Promise<{
versions: string[];
majors: { major: number; latest: string; lts?: string }[];
}>;
export = DefaultFunction;
}
in typings\all-node-versions\index.d.ts
with "typeRoots": ["./node_modules/@types", "./typings"],
in tsconfig.json
I'm writing a script that would use listr and nodeenv to install deps and run tests for all projects recursively, it detects required node and npm versions from package.json engines section, and to optimize it I need to know if node version I'm installing is shipped with npm version that I need by default, or if I need to pass --npm=... --with-npm
to nodeenv.
Something like [{node: "16.3.0", npm: "7.15.1"}, ...]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.