Registry / year
library0.2.1jsnpmunverified

The `year` package is a simple JavaScript utility designed to retrieve the current year, formatted as either two or four digits. Its primary function is to return `YYYY` by default or `YY` when explicitly requested. The current version, 0.2.1, was last updated in 2014, making it effectively abandoned and unmaintained. As such, there is no active release cadence, and it lacks support for modern JavaScript features like ESM. It differentiates itself through its extreme simplicity and minimal footprint, although modern alternatives offer more robust date formatting and are actively maintained. It targets Node.js environments version 0.8 and above, reflecting its age.

npm install year
INSTALL
IMPORT
SIG · YEAR
Y
year
javascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

year
const year = require('year');
import year from 'year';
This package is CommonJS-only and does not provide an ESM export. Attempting to import it with `import` will result in an error in pure ESM projects.
year()
const currentYear = year();
The default call returns the four-digit year (YYYY).
year('yy')
const twoDigitYear = year('yy');
Pass 'yy' as an argument to retrieve the two-digit year.

Demonstrates how to import the `year` utility and use it to get the current year in both two-digit and four-digit formats.

const year = require('year'); // Get the current year (e.g., 2014 when this was published) const fullYear = year(); console.log(`Current full year: ${fullYear}`); // Get the current year in 4-digit format (explicitly) const explicitFullYear = year('yyyy'); console.log(`Explicit full year: ${explicitFullYear}`); // Get the current year in 2-digit format const twoDigitYear = year('yy'); console.log(`Two-digit year: ${twoDigitYear}`); // Example using current date to demonstrate expected output (since 'year' is fixed to 2014 in examples) const actualCurrentYear = new Date().getFullYear(); console.log(`Actual current year (YYYY): ${actualCurrentYear}`); console.log(`Actual current year (YY): ${String(actualCurrentYear).slice(-2)}`);
Debug
Known issues
breakingThis package is abandoned and has not been updated since 2014. It relies on an internal date mechanism that might be outdated or behave unexpectedly in modern JavaScript runtimes or with time zone changes. It is strongly recommended to use `new Date().getFullYear()` for reliability.
fix
Replace `year()` calls with `new Date().getFullYear()` and `String(new Date().getFullYear()).slice(-2)` for two-digit formatting.
affects: >=0.2.1
gotchaThe package is CommonJS-only. Attempting to use `import` syntax in a pure ESM module will lead to an `ERR_REQUIRE_ESM` error.
fix
Ensure your project is configured for CommonJS, or use dynamic `import()` if absolutely necessary within an ESM context, though direct date manipulation is preferred.
affects: >=0.2.1
deprecatedThe package is unmaintained, meaning it will not receive security updates, bug fixes, or compatibility improvements for newer Node.js versions or browser environments. Using it may introduce security vulnerabilities or unexpected behavior.
fix
Migrate to standard JavaScript `Date` object methods or a actively maintained date utility library.
affects: >=0.2.1
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module ... from ... not supported.
Attempting to `require()` an ESM module, or more likely, trying to `import` this CJS module in an ESM context.
fix
This package is CommonJS. If your project is ESM, either switch to `new Date().getFullYear()` directly, or convert your module to CommonJS. Do not use `import year from 'year';`
TypeError: year is not a function
Likely due to incorrect import (e.g., `import { year } from 'year'` instead of `import year from 'year'`) or a failed CommonJS `require` where the module wasn't found.
fix
Ensure the CommonJS `const year = require('year');` syntax is used correctly. Verify the package is installed.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
year — npm install year · libregistry