question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when running from pnpm installation

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
elliottsjcommented, Oct 21, 2019

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.

0reactions
aleccool213commented, Jun 19, 2019

@lgandecki That’s fine. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

error when trying to install pnpm when Node.js is not ... - GitHub
Tip: My username in Windows is 'Matheus Corocher'. I think the problem can be that my username has blank space and therefore gives...
Read more >
How to warn or error when using "npm install" - Stack Overflow
These generally work either via a preinstall script or by (ab)using the "engines" property in package.json. The node.js project is working on a ......
Read more >
nodenv + pnpm "Error running pnpm install..." : WEB-51042
Error running 'pnpm install in vue-dynamic-test' Specify a correct path to an npm or yarn package: no such directory "/Users/tomshaw/. nodenv/shims/pnpm" ...
Read more >
Build Error at npx pnpm@7.0.0 install step - Dremio Community
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.1:npx (pnpm install) on project dremio-ui-lib: Failed to run ...
Read more >
pnpm/pnpm - Gitter
Is there a command to run pnpm install for the closest package.json file to my ... (packages/api-extractor-config) ERROR· Command failed with exit code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found