{"id":15068,"library":"year","title":"Current Year Utility","description":"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.","status":"abandoned","version":"0.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/jonschlinkert/year","tags":["javascript"],"install":[{"cmd":"npm install year","lang":"bash","label":"npm"},{"cmd":"yarn add year","lang":"bash","label":"yarn"},{"cmd":"pnpm add year","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import year from 'year';","symbol":"year","correct":"const year = require('year');"},{"note":"The default call returns the four-digit year (YYYY).","symbol":"year()","correct":"const currentYear = year();"},{"note":"Pass 'yy' as an argument to retrieve the two-digit year.","symbol":"year('yy')","correct":"const twoDigitYear = year('yy');"}],"quickstart":{"code":"const year = require('year');\n\n// Get the current year (e.g., 2014 when this was published)\nconst fullYear = year();\nconsole.log(`Current full year: ${fullYear}`);\n\n// Get the current year in 4-digit format (explicitly)\nconst explicitFullYear = year('yyyy');\nconsole.log(`Explicit full year: ${explicitFullYear}`);\n\n// Get the current year in 2-digit format\nconst twoDigitYear = year('yy');\nconsole.log(`Two-digit year: ${twoDigitYear}`);\n\n// Example using current date to demonstrate expected output (since 'year' is fixed to 2014 in examples)\nconst actualCurrentYear = new Date().getFullYear();\nconsole.log(`Actual current year (YYYY): ${actualCurrentYear}`);\nconsole.log(`Actual current year (YY): ${String(actualCurrentYear).slice(-2)}`);","lang":"javascript","description":"Demonstrates how to import the `year` utility and use it to get the current year in both two-digit and four-digit formats."},"warnings":[{"fix":"Replace `year()` calls with `new Date().getFullYear()` and `String(new Date().getFullYear()).slice(-2)` for two-digit formatting.","message":"This 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.","severity":"breaking","affected_versions":">=0.2.1"},{"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.","message":"The package is CommonJS-only. Attempting to use `import` syntax in a pure ESM module will lead to an `ERR_REQUIRE_ESM` error.","severity":"gotcha","affected_versions":">=0.2.1"},{"fix":"Migrate to standard JavaScript `Date` object methods or a actively maintained date utility library.","message":"The 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.","severity":"deprecated","affected_versions":">=0.2.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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';`","cause":"Attempting to `require()` an ESM module, or more likely, trying to `import` this CJS module in an ESM context.","error":"ERR_REQUIRE_ESM: require() of ES Module ... from ... not supported."},{"fix":"Ensure the CommonJS `const year = require('year');` syntax is used correctly. Verify the package is installed.","cause":"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.","error":"TypeError: year is not a function"}],"ecosystem":"npm"}