Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG] Error when working with npm workspaces

Open
#605 1 comment 0 reactions 1 assignee View on GitHub

@kay-schecker is already working on this.

Since Jan 30, 2022.

Assessment

This issue has not been assessed yet.

Description

bug

🐛 Bug Report:

Describe the bug

The generator crashes with the [error] Required option '-i' is missing error when running with different cwd.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a npm project with two workspaces: packages/client and packages/server (server probably isn't even necessary)
  2. Save a spec in packages/openapi.yaml
  3. Reference it in packages/client/openapitools.json via "inputSpec": "../openapi.yaml"
  4. Add a script in client: "openapi": "openapi-generator-cli generate" and run it
    • It works ✔️
  5. Add a script in root "openapi": "npm run openapi --workspaces --if-present" and run it
    • See error ❌
    • Generates a openapitools.json in the root directory
Failing workaround

I created a packages/client/openapi.js script and let it run in client via "openapi": "node openapi.js" , but this also fails in the same way.

// try forcing the cwd to the client directory (works when checking with pwd command)
const child = require('child_process').exec('openapi-generator-cli generate', { cwd: __dirname });
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('exit', code => process.exit(code));
Expected behavior

I expect the generator to always find the file.

Operation System:
  • OS: Windows
  • Version 10
Package System:
  • npm v8.3.0
Dominant language
TypeScript
Stars
2k
Forks
208
Avg merge
7h 12m
Merged PRs (30d)
6

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenAPITools/openapi-generator-cli

All issues in OpenAPITools/openapi-generator-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.