{"id":13458,"library":"liferay-npm-bundler","title":"Liferay NPM Bundler","description":"liferay-npm-bundler is a specialized Command Line Interface (CLI) utility designed to process Liferay widget projects and produce OSGi bundles, encapsulating the necessary npm dependencies for deployment to the Liferay Portal. Functioning similarly to bundlers like Webpack, it uniquely targets Liferay Portal as its platform, handling the intricacies of OSGi module packaging for frontend assets. This includes linking packages in the browser and facilitating the sharing of common module versions across widgets rather than each loading its own copy. It converts application resources and npm dependencies into a Liferay OSGi bundle, preparing them for deployment via a standard widget build (e.g., Gradle). As of its latest version, 2.32.2, it was part of the actively developed `liferay-frontend-projects` monorepo. However, it has been officially deprecated as of Liferay 2024.Q4/Portal GA129 and is scheduled for future removal, with Liferay shifting towards alternative frontend development and optimization strategies.","status":"deprecated","version":"2.32.2","language":"javascript","source_language":"en","source_url":"https://github.com/liferay/liferay-frontend-projects","tags":["javascript"],"install":[{"cmd":"npm install liferay-npm-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add liferay-npm-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add liferay-npm-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary CLI function can be imported as the package's default export for programmatic execution.","wrong":"const main = require('liferay-npm-bundler');","symbol":"main","correct":"import main from 'liferay-npm-bundler';"},{"note":"The core bundling logic is exposed via the `bundle` function from an internal module, useful for custom build processes.","wrong":"const { bundle } = require('liferay-npm-bundler/bundler');","symbol":"bundle","correct":"import { bundle } from 'liferay-npm-bundler/lib/bundler';"},{"note":"For advanced scenarios, configuration merging logic can be accessed directly from its internal module.","wrong":"const { getMergedConfig } = require('liferay-npm-bundler/config');","symbol":"getMergedConfig","correct":"import { getMergedConfig } from 'liferay-npm-bundler/lib/config';"}],"quickstart":{"code":"{\n  \"name\": \"my-liferay-widget\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A sample Liferay widget\",\n  \"main\": \"src/index.js\",\n  \"scripts\": {\n    \"build\": \"liferay-npm-bundler\"\n  },\n  \"dependencies\": {\n    \"react\": \"^18.0.0\",\n    \"react-dom\": \"^18.0.0\"\n  },\n  \"devDependencies\": {\n    \"liferay-npm-bundler\": \"^2.32.2\"\n  }\n}\n\n// To run the bundler:\n// npm install\n// npm run build\n// This will process your project and dependencies into an OSGi bundle compatible with Liferay Portal.\n","lang":"javascript","description":"Demonstrates `liferay-npm-bundler` integration into `package.json` scripts for a typical Liferay widget project."},"warnings":[{"fix":"Consult Liferay's official documentation for current best practices and recommended alternatives for frontend development and deployment.","message":"`liferay-npm-bundler` has been officially deprecated as of Liferay 2024.Q4/Portal GA129 and is slated for removal in future releases. Users should migrate to alternative Liferay frontend development strategies.","severity":"deprecated","affected_versions":">=2.32.2"},{"fix":"Upgrade `liferay-npm-bundler` to version 2.32.1 or later, which includes a fix for the `globby` compatibility issue.","message":"Version 2.32.0 (and potentially earlier minor versions) had a breaking change related to an updated `globby` dependency, leading to 'ENOENT' errors during builds in some environments.","severity":"breaking","affected_versions":"2.32.0"},{"fix":"Always check the official Liferay Node.js compatibility matrix for your Liferay DXP version and ensure your development environment adheres to those specifications.","message":"Node.js and npm version compatibility is crucial. Liferay frontend tools, including this bundler, are designed for specific Node.js and npm versions. Using unsupported versions can lead to build failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Refer to Liferay's documentation for the compatibility matrix between `liferay-npm-bundler` and Liferay DXP versions to ensure proper alignment.","message":"`liferay-npm-bundler` is tightly coupled with Liferay Portal versions. Using an incompatible version of the bundler with your target Liferay Portal instance can result in deployment failures or unexpected runtime behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid attempting to use Webpack-specific loader configurations or plugins directly with `liferay-npm-bundler`. Understand its unique approach to module loading and rule processing for Liferay's AMD environment.","message":"Unlike generic bundlers such as Webpack, `liferay-npm-bundler` targets an AMD loader. Its loader mechanisms are not compatible with Webpack loaders, which can be a source of confusion for developers familiar with other bundling tools.","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":"Check the detailed output above the error for specific messages. Verify `package.json` scripts, `.npmbundlerrc` configuration, Node.js/npm versions, and Liferay Portal compatibility.","cause":"A generic error indicating that the `liferay-npm-bundler` CLI process failed, often due to configuration issues, incompatible dependencies, or environment problems.","error":"Error: Command failed with exit code 1: liferay-npm-bundler"},{"fix":"Ensure the dependency is correctly listed in `package.json`, installed via `npm install`, and that any custom module resolution paths in `.npmbundlerrc` are accurate.","cause":"The bundler could not locate a required npm package within your project's dependency tree or node_modules.","error":"Module not found: Can't resolve 'some-dependency' in 'some-path'"},{"fix":"Update or downgrade `liferay-npm-bundler` to a version officially supported by your Liferay Portal version, as specified in Liferay's compatibility documentation.","cause":"The installed `liferay-npm-bundler` version is incompatible with the target Liferay Portal version for which the OSGi bundle is being prepared.","error":"Error: Liferay Portal version X is not supported by this bundler version."},{"fix":"Upgrade `liferay-npm-bundler` to version 2.32.1 or higher to resolve the `globby` compatibility issue.","cause":"This specific error can occur due to an incompatibility with the `globby` dependency, particularly in versions prior to 2.32.1.","error":"ENOENT: no such file or directory, scandir 'path/to/missing/file'"},{"fix":"Review your `liferay-npm-bundler` configuration files against the official documentation to ensure all options and their syntax are correct and supported by your bundler version.","cause":"A configuration option in your `.npmbundlerrc` file or `package.json` `liferay-npm-bundler` section is not recognized or is malformed.","error":"Invalid configuration option: 'someOption'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"liferay-npm-bundler","cli_version":null}