Skip to content

Commit 0cea251

Browse files
committed
fix: dont fail on resolution of not installed packages
1 parent a568a58 commit 0cea251

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/apify/src/utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,22 @@ export function logSystemInfo() {
3232
* @internal
3333
*/
3434
export function checkCrawleeVersion() {
35+
const resolve = (name: string) => {
36+
try {
37+
return require.resolve(name);
38+
} catch {
39+
return name;
40+
}
41+
};
42+
3543
const paths = [
3644
// when users install `crawlee` package, we need to check its core dependency
3745
normalize(`${process.cwd()}/node_modules/crawlee/node_modules/@crawlee/core/package.json`),
3846
// when users install `@crawlee/cheerio` or other crawler package, we need to check the dependency under basic crawler package
3947
normalize(`${process.cwd()}/node_modules/@crawlee/basic/node_modules/@crawlee/core/package.json`),
4048
// also check paths via `require.resolve` to support pnpm
41-
require.resolve('crawlee/package.json'),
42-
require.resolve('@crawlee/basic/package.json'),
49+
resolve('crawlee/package.json'),
50+
resolve('@crawlee/basic/package.json'),
4351
];
4452

4553
for (const path of paths) {

0 commit comments

Comments
 (0)