navigator
History
--no-experimental-global-navigator CLI flag.A partial implementation of window.navigator.
numberThe navigator.hardwareConcurrency read-only property returns the number of
logical processors available to the current Node.js instance.
console.log(`This process is running on ${navigator.hardwareConcurrency} logical processors`);
stringThe navigator.language read-only property returns a string representing the
preferred language of the Node.js instance. The language will be determined by
the ICU library used by Node.js at runtime based on the
default language of the operating system.
The value is representing the language version as defined in RFC 5646.
The fallback value on builds without ICU is 'en-US'.
console.log(`The preferred language of the Node.js instance has the tag '${navigator.language}'`);
string[]The navigator.languages read-only property returns an array of strings
representing the preferred languages of the Node.js instance.
By default navigator.languages contains only the value of
navigator.language, which will be determined by the ICU library used by
Node.js at runtime based on the default language of the operating system.
The fallback value on builds without ICU is ['en-US'].
console.log(`The preferred languages are '${navigator.languages}'`);
The navigator.locks read-only property returns a LockManager instance that
can be used to coordinate access to resources that may be shared across multiple
threads within the same process. This global implementation matches the semantics
of the browser LockManager API.
// Request an exclusive lock await navigator.locks.request('my_resource', async (lock) => { // The lock has been acquired. console.log(`Lock acquired: ${lock.name}`); // Lock is automatically released when the function returns }); // Request a shared lock await navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => { // Multiple shared locks can be held simultaneously console.log(`Shared lock acquired: ${lock.name}`); });
// Request an exclusive lock navigator.locks.request('my_resource', async (lock) => { // The lock has been acquired. console.log(`Lock acquired: ${lock.name}`); // Lock is automatically released when the function returns }).then(() => { console.log('Lock released'); }); // Request a shared lock navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => { // Multiple shared locks can be held simultaneously console.log(`Shared lock acquired: ${lock.name}`); }).then(() => { console.log('Shared lock released'); });
See worker_threads.locks for detailed API documentation.
stringThe navigator.platform read-only property returns a string identifying the
platform on which the Node.js instance is running.
console.log(`This process is running on ${navigator.platform}`);
stringThe navigator.userAgent read-only property returns user agent
consisting of the runtime name and major version number.
console.log(`The user-agent is ${navigator.userAgent}`); // Prints "Node.js/21"