How to Execute Global Packages

How to Execute Global Packages

I'm trying to start an AWS CDK Project using pnpm v8.0.0 as my package manager. Then, I've followed these steps:

  • Installed [email protected] globally: pnpm install -g aws-cdk
  • Created a new directory: mkdir my-dir && cd my-dir
  • Tried to execute the 'init' command: pnpm exec cdk init app --language=typescript

However, I've got the following pnpm error: ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Cannot read properties of undefined (reading '/home/user/my-dir')

I've tried to workaround this by installing aws-cdk locally: pnpm init && pnpm install -D aws-cdk and then running the same pnpm exec... command and then I've got a aws-sdk error: cdk init cannot be run in a non-empty directory!

The pnpm docs is clear about exec: Execute a shell command in scope of a project.

My question is: How use pnpm to execute global packages?

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.