{"id":13262,"library":"grunt-build-number","title":"Grunt Build Number","description":"This package, `grunt-build-number`, is a Grunt plugin designed to manage and increment a build number within project configuration files like `package.json` or `bower.json`. Its current stable version is 1.0.0, released in 2014, indicating a very slow or effectively abandoned release cadence since its initial launch. It provides a straightforward mechanism to automatically bump a specified field (defaulting to 'build') in a JSON file during the build process, which is highly useful for versioning deployments or artifacts within continuous integration workflows. It differentiates itself by being a dedicated Grunt task for this specific purpose, integrating directly into a Grunt-based workflow rather than requiring separate scripts or manual updates. The plugin requires Grunt to be installed and configured as a peer dependency in the project. Developers typically use it to ensure unique build identifiers for build artifacts or releases.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/creynders/grunt-build-number","tags":["javascript","gruntplugin","build","version"],"install":[{"cmd":"npm install grunt-build-number","lang":"bash","label":"npm"},{"cmd":"yarn add grunt-build-number","lang":"bash","label":"yarn"},{"cmd":"pnpm add grunt-build-number","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for Grunt task execution.","package":"grunt","optional":false}],"imports":[{"note":"Grunt plugins are loaded via the Grunt API within `Gruntfile.js`, not via standard JavaScript module imports.","wrong":"import { buildnumber } from 'grunt-build-number';","symbol":"Loading the Grunt Plugin","correct":"grunt.loadNpmTasks('grunt-build-number');"},{"note":"The task configuration is defined within the `buildnumber` object inside `grunt.initConfig()`. It must include at least one target, even if empty, for the task to be valid.","wrong":"grunt.initConfig({\n  // Missing 'buildnumber' or targets\n});","symbol":"Configuring the Task","correct":"grunt.initConfig({\n  buildnumber: {\n    your_target: {}\n  }\n});"},{"note":"Grunt tasks are executed via the `grunt` command-line interface, specifying the task name.","wrong":"node grunt-build-number","symbol":"Running the Task (CLI)","correct":"grunt buildnumber"}],"quickstart":{"code":"// Gruntfile.js\nmodule.exports = function(grunt) {\n  grunt.initConfig({\n    buildnumber: {\n      package: {\n        // Default options will look for package.json and bump 'build' field\n      },\n      customFiles: {\n        options: {\n          field: 'releaseId'\n        },\n        files: ['package.json', 'manifest.json']\n      }\n    }\n  });\n\n  // Load the plugin that provides the \"buildnumber\" task.\n  grunt.loadNpmTasks('grunt-build-number');\n\n  // Register a default task to run buildnumber\n  grunt.registerTask('default', ['buildnumber:package']);\n};\n\n// To run from your terminal:\n// $ npm install grunt --save-dev\n// $ npm install grunt-build-number --save-dev\n// $ grunt\n// (This will run the 'package' target and update 'build' in package.json)\n// $ grunt buildnumber:customFiles\n// (This will run the 'customFiles' target and update 'releaseId' in package.json and manifest.json)","lang":"javascript","description":"Demonstrates how to load the plugin, configure a default and custom target for the `buildnumber` task in `Gruntfile.js`, and execute them via the Grunt CLI."},"warnings":[{"fix":"Ensure your Gruntfile.js configuration includes `buildnumber: { yourTargetName: {} }` or similar.","message":"The `buildnumber` configuration object in `grunt.initConfig()` *must* include at least one target definition, even if it's an empty object. Without a target, Grunt will not be able to locate and run the task correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Thoroughly test compatibility with your current environment. Consider migrating to a more actively maintained build versioning solution, or a custom script if this plugin exhibits issues.","message":"This package has not been updated since its initial release in 2014 (v1.0.0). It may have compatibility issues with newer versions of Node.js, npm, or Grunt itself, which has seen updates since then. It is effectively unmaintained.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Specify a unique `options.field` value, e.g., `field: 'appBuildNumber'`, to avoid collisions with existing data in your configuration files.","message":"The `options.field` property (default 'build') determines the key in your JSON file where the build number is stored. If this field already exists in the target JSON file and is used for another purpose, its value will be overwritten by the task's build number.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Add `grunt.loadNpmTasks('grunt-build-number');` to your `Gruntfile.js` after defining `grunt.initConfig()`.","cause":"The Grunt plugin was not loaded into the Grunt environment.","error":"Warning: Task \"buildnumber\" not found."},{"fix":"Ensure `grunt.initConfig()` includes a `buildnumber` object with at least one target, e.g., `buildnumber: { default: {} }`.","cause":"The `buildnumber` task configuration object is missing from `grunt.initConfig()` or does not contain any defined targets, which is required by Grunt for multi-tasks.","error":"Fatal error: Object doesn't contain any property 'buildnumber'"},{"fix":"Install Grunt locally using `npm install grunt --save-dev`.","cause":"The 'grunt' package, a required peer dependency, is not installed in the project.","error":"Error: Cannot find module 'grunt'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}