Cypress-cucumber-preprocessor: Error when running from pnpm installation

Created on 19 Jun 2019  路  5Comments  路  Source: TheBrainFamily/cypress-cucumber-preprocessor

cypress-cucumber-preprocessor includes templates which generates application code that imports gherkin, e.g.

const createCucumber = (spec, toRequire) =>
  `
  ...
  const {Parser, Compiler} = require('gherkin');
  ...
  `;

source: https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/blob/e0d043d062abd54a4cb5ef5c0ad65a93a6c63c26/lib/loader.js#L19

Normally, this is not a problem when using popular package managers like
npm / yarn because 'gherkin' is a direct
dependency of cypress-cucumber-preprocessor, which is hoisted to the root
node_modules folder, enabling it to be found by webpack / node:

node_modules/
  gherkin/
    ...
  cypress-cucumber-preprocessor

But when using strict package managers such as pnpm (or yarn pnp),
gherkin cannot be resolved because it can only be resolved
by code inside the cypress-cucumber-preprocessor package:

node_modules/
  cypress-cucumber-preprocessor
    ...
    node_modules/
      gherkin/
      ...

Solution:

  • Add gherkin to peerDependencies so users must install it themselves.
  • Also add gherkin to devDependencies so it can run its own tests

similar issues:

https://github.com/emotion-js/emotion/pull/1254

Most helpful comment

This was fixed in #191:

https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/pull/191/files#diff-7c7d4918b118d27d18538f53b8155e88L19

The require('gherkin') expression no longer exists in the template, so this dependency hoisting problem is gone.

All 5 comments

Oh, interesting...
But won't that mean that the plugin will stop working (with an ugly error) for all the existing users that decide to upgrade? If you install gherkin manually in your top level repo, will it work?

@lgandecki yes :( a breaking change. Installing it manually works in your top level repo, a peer dependancy :)

hmm... So how about we add information to the documentation that if you use strict package manager you should add gherkin to your dependencies manually? I think we should make it the smoothest experience for the majority of users.. not the other way around.

@lgandecki That's fine. 馃憤

This was fixed in #191:

https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/pull/191/files#diff-7c7d4918b118d27d18538f53b8155e88L19

The require('gherkin') expression no longer exists in the template, so this dependency hoisting problem is gone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

badeball picture badeball  路  5Comments

ngocthuan1208 picture ngocthuan1208  路  6Comments

hiaux0 picture hiaux0  路  6Comments

leegee picture leegee  路  4Comments

PrinceJohn picture PrinceJohn  路  3Comments