1

I am using a pnpm workspace with different packages to distinguish the modules. I intend to use CodeceptJS as my test automation framework but whenever I install and initialize CodeceptJS in the root directory (pnpm add -w codeceptjs playwright then pnpm dlx codeceptjs init), it is not recognized within the individual packages.

If I do pnpm dlx codeceptjs init within a package, it gives this warning: "WARNING: CodeceptJS is not installed locally. It is recommended to switch to local installation" and then installs CodeceptJS in that package. Is it possible to have one shared instance of CodeceptJS with Playwright for a monorepo setup as opposed to installing it one-by-one in all packages?

Here is my directory structure:

root
├──node_modules
│  
├──packages
│  ├──package1
│  │   ├──node_modules
│  │   └──package.json
│  └──package2
│     ├──node_modules
│     └──package.json
|  
└──package.json
Lewis Munene
  • 134
  • 7

1 Answers1

1

In order to run the locally installed instance of codeceptjs, you need to run one of these commands:

pnpm exec codeceptjs init

or

pnpm codeceptjs init

pnpm dlx downloads the package and executes it.

Unlike npx, which is checking if a package exists locally and runs it or installs it in a hidden location, pnpm has two separate commands. One for just running a local package (pnpm exec) and another one for downloading and running.

Zoltan Kochan
  • 5,180
  • 29
  • 38
  • Works fine. For CodeceptJS in particular, when you do `pnpm exec codeceptjs init` in the package and select that you want to use Typescript, it will still install Typescript and CodeceptJs in that package. I guess it's written into the CodeceptJS init wizard. You can fix this by manually uninstalling CodeceptJS and Typescript from that package so that you're left with the root installations – Lewis Munene Mar 23 '23 at 07:26