https://github.com/cheeriojs/cheerio/blob/main/package.json#L30
The unpublished dependency, cheerio-select from GitHub will attempt to run the prepare script on pnpm install.
npm install works, though I would expect it to fail as well (https://docs.npmjs.com/cli/v6/using-npm/scripts#life-cycle-scripts).
To reproduce:
Create a package.json with enzyme as a dep (or any package that requires cheerio).
{
"name": "foo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"enzyme": "^3.11.0"
}
}
Run:
$ pnpm install
Results:
../node_modules/cheerio-select prepare$ npm run build
β > [email protected] build
β > tsc
β src/helpers.ts(12,5): error TS4060: Return type of exported function has or is using private name 'plain'.
β src/helpers.ts(12,10): error TS1005: ',' expected.
β src/helpers.ts(12,26): error TS4060: Return type of exported function has or is using private name 'filtered'.
β src/helpers.ts(12,34): error TS1005: ',' expected.
β npm ERR! code 1
β npm ERR! path /Users/mshick/Code/mshick/foo/node_modules/.pnpm/github.com/cheeriojs/cheerio-select@b98d6200519fe229904f2ae39ea44ed8e6d19182/node_modules/cheerio-select
β npm ERR! command failed
β npm ERR! command sh -c tsc
β npm ERR! A complete log of this run can be found in:
β npm ERR! /Users/mshick/.npm/_logs/2020-12-21T20_04_30_488Z-debug.log
ββ Failed in 2s
βERRORβ Command failed with exit code 1.
Potentially related: our build environment did not have git installed so builds started failing because a regular npm install failed due to git not being available.
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/cheeriojs/cheerio-select.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Is it possible to get cheerio-select published to npm prior to the next release?
Same problem here:

@xiaoaifresh If it helps, we decided to pin to a previously release in package.json in the meantime.
@xiaoaifresh If it helps, we decided to pin to a previously release in package.json in the meantime.
Could you please briefly describe to me how you do that?
@xiaoaifresh you could try use the "resolutions" property in package.json
Thanks for the report, and sad to hear that this is causing issues for many people.
Is it possible to get cheerio-select published to npm prior to the next release?
This is unfortunately still blocked by https://github.com/cheeriojs/cheerio-select/issues/2. I am trying to get this resolved, but didn't want to delay the next release because of it.
@xiaoaifresh If it helps, we decided to pin to a previously release in package.json in the meantime.
Could you please briefly describe to me how you do that?
You can specify a specific version in your package.json, like this:
"cheerio": "1.0.0-rc.3",
npm installworks, though I would expect it to fail as well (https://docs.npmjs.com/cli/v6/using-npm/scripts#life-cycle-scripts).
That link states:
NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.
This is supported behavior by npm, although I can see how it is a bit surprising.
I very much agree that this is not the best solution and hope to publish cheerio-select properly soon.
This is also causing an issue for an enzyme user: https://github.com/enzymejs/enzyme/issues/2487 not sure if they're using pnpm, but git deps are generally a very bad idea for many reasons.
Could you publish a fork of cheerio-select, under a scope, in the meantime?
Also having a problem with cheerio-select on my Gatsby site. Maybe a related problem?
Error in "/node_modules/gatsby-plugin-offline/gatsby-node.js": Cannot find module
'/cheerio-select/lib/index.js'. Please verify that the package.json has a valid "main" entry
Error: Cannot find module '/node_modules/cheerio-select/lib/index.js'. Please verify that the package.json has a valid "main" entry
I see the following in my terminal, which wasn't there before:
"cheerio > [email protected]" has unmet peer dependency "@types/node@^14.11.2"."
I've published 1.0.0-rc.5 that fixes this issue. Sorry for the trouble everyone, hope all is good now!
Most helpful comment
I've published
1.0.0-rc.5that fixes this issue. Sorry for the trouble everyone, hope all is good now!