{"id":15708,"library":"monopack-cli","title":"Monopack CLI","description":"Monopack CLI is a JavaScript bundler designed for Node.js monorepo applications, aiming to create static, deterministic deliverables. It bundles all imported monorepo sources into a single `main.js` file, alongside a pruned `package.json`, `yarn.lock`, and `node_modules` containing only the truly used third-party dependencies. Originally conceived to streamline continuous integration and deployment for serverless functions, micro-services, and monolithic servers within a monorepo structure, its last known stable release is 0.2.6, published in September 2018. Due to its age and lack of recent updates, the project appears to be abandoned, and its compatibility with modern Node.js and Yarn versions is uncertain.","status":"abandoned","version":"0.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/flegall/monopack","tags":["javascript"],"install":[{"cmd":"npm install monopack-cli","lang":"bash","label":"npm"},{"cmd":"yarn add monopack-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add monopack-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime environment. Requires Node.js >= 6.14.4.","package":"node","optional":false},{"reason":"Required for deterministic dependency installation and consistent builds. Requires Yarn >= 1.3.2.","package":"yarn","optional":false}],"imports":[{"note":"This package is a CLI tool and not intended for programmatic import. Use 'yarn global add monopack' or 'npm install -g monopack' to install globally.","wrong":"require('monopack')","symbol":"monopack (global installation)","correct":"monopack <command>"},{"note":"After installing locally with 'yarn add -D monopack', invoke through Yarn's run script mechanism.","wrong":"monopack <command>","symbol":"monopack (local installation via Yarn)","correct":"yarn run monopack <command>"},{"note":"After installing locally with 'npm install --save-dev monopack', invoke directly from the local bin directory.","wrong":"monopack <command>","symbol":"monopack (local installation via npm)","correct":"./node_modules/.bin/monopack <command>"}],"quickstart":{"code":"import { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\n\n// Create a temporary directory for the mock monorepo\nconst tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'monopack-demo-'));\nconst appPackageDir = path.join(tempDir, 'packages', 'my-app');\nconst sharedLibDir = path.join(tempDir, 'packages', 'shared-lib');\n\nconsole.log(`Setting up mock monorepo in: ${tempDir}`);\n\n// Create application package structure\nfs.mkdirSync(path.join(appPackageDir, 'src'), { recursive: true });\nfs.writeFileSync(path.join(appPackageDir, 'package.json'), JSON.stringify({\n  name: 'my-app',\n  version: '1.0.0',\n  main: 'src/main.js',\n  dependencies: {\n    'lodash': '^4.17.21' // Third-party dependency\n  }\n}, null, 2));\nfs.writeFileSync(path.join(appPackageDir, 'src', 'main.js'), `\n  const _ = require('lodash');\n  const { getMessage } = require('shared-lib'); // Monorepo dependency\n  console.log(_.toUpper(getMessage('Monopack Demo')));\n`);\n\n// Create shared library package structure\nfs.mkdirSync(sharedLibDir, { recursive: true });\nfs.writeFileSync(path.join(sharedLibDir, 'package.json'), JSON.stringify({\n  name: 'shared-lib',\n  version: '1.0.0',\n  main: 'index.js'\n}, null, 2));\nfs.writeFileSync(path.join(sharedLibDir, 'index.js'), `\n  exports.getMessage = (topic) => 'Hello from shared-lib, ' + topic + '!';\n`);\n\n// Simulate monorepo setup with yarn and install local monopack\ntry {\n  console.log('\\nInstalling dependencies and linking shared-lib...');\n  execSync(`cd ${appPackageDir} && yarn add file:${sharedLibDir}`, { stdio: 'inherit' });\n  execSync(`cd ${appPackageDir} && yarn install`, { stdio: 'inherit' });\n  execSync(`cd ${appPackageDir} && yarn add -D monopack-cli@0.2.6`, { stdio: 'inherit' });\n\n  console.log('\\n--- Running monopack build ---');\n  const outputDir = path.join(appPackageDir, 'dist');\n  // Execute monopack locally using its path in node_modules\n  execSync(`cd ${appPackageDir} && ./node_modules/.bin/monopack build src/main.js --out-dir ${outputDir}`, { stdio: 'inherit' });\n\n  console.log(`\\nBuild successful. Output directory contents for 'my-app': ${outputDir}`);\n  console.log(fs.readdirSync(outputDir));\n\n  console.log('\\n--- Running the bundled application ---');\n  // To run the bundled application, it usually requires its own node_modules\n  // which monopack should have generated in the output directory.\n  execSync(`cd ${outputDir} && node main.js`, { stdio: 'inherit' });\n\n} catch (error: any) {\n  console.error('\\nAn error occurred during the quickstart execution:', error.message);\n  if (error.stdout) console.error('stdout:', error.stdout.toString());\n  if (error.stderr) console.error('stderr:', error.stderr.toString());\n} finally {\n  console.log(`\\nCleaning up temporary directory: ${tempDir}`);\n  fs.rmSync(tempDir, { recursive: true, force: true });\n}\n","lang":"typescript","description":"This example demonstrates how to set up a minimal mock Node.js monorepo project and use `monopack build` to bundle an application, including a locally linked shared library and a third-party dependency, into a static deliverable. It then executes the resulting bundle."},"warnings":[{"fix":"Consider using actively maintained monorepo bundling solutions like Nx, Lerna, Turborepo, or custom Webpack/Rollup configurations tailored for monorepos. If you must use Monopack, use Node.js < 10 and Yarn 1.x.","message":"Monopack CLI appears to be an abandoned project, with its last release (v0.2.6) in September 2018. It is highly unlikely to be compatible with modern Node.js versions (e.g., Node.js 16+ or newer) or Yarn 2+.","severity":"breaking","affected_versions":">=0.2.6"},{"fix":"Utilize Yarn (version >= 1.3.2) for package management within your monorepo to ensure consistent builds and dependency resolution.","message":"Deterministic dependency collection is only guaranteed if your project uses Yarn (>= 1.3.2). While Monopack can work with npm, the resulting dependency tree might not be as predictable.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Install dynamically required dependencies (e.g., database drivers) directly in the application package that uses them before running Monopack, then specify them with `-m` or `--with-extra-module` option.","message":"When adding extra modules via `--with-extra-module`, ensure that the package is installed in the same monorepo package as your main entrypoint. If it's installed elsewhere, Monopack might pick up an unintended version or fail to resolve it.","severity":"gotcha","affected_versions":">=0.2.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use the `--with-extra-module <module-name>` CLI option to explicitly include such dependencies. For example: `monopack build main.js -m mysql`.","cause":"Monopack's static analysis may not detect modules that are dynamically required at runtime (e.g., certain database drivers or plugins).","error":"Error: Cannot find module 'some-dynamically-required-module'"},{"fix":"If installed globally, ensure your global npm/yarn bin directory is in your PATH. If installed locally, invoke it via `yarn run monopack <command>` (if configured in `package.json` scripts) or `./node_modules/.bin/monopack <command>`.","cause":"The `monopack` command is not accessible in your system's PATH. This typically happens if it's not installed globally, or if installed locally, it's not being invoked correctly.","error":"command not found: monopack"}],"ecosystem":"npm"}