-
How can I change the check existence (
async function determineNodeModulesPath(dir: string, packageName: string): Promise<string | undefined> {
const nodeModulesPath: string | undefined = path.join(dir, 'node_modules', packageName);
if (await fs.pathExists(nodeModulesPath)) {
return nodeModulesPath;
}
return findAncestorNodeModulesPath(dir, packageName);
} Currentfs.pathExists(nodeModulesPath) = false Expectedfs.pathExists(nodeModulesPath) = true |
Beta Was this translation helpful? Give feedback.
Answered by
merceyz
Jun 8, 2024
Replies: 1 comment
-
Use require.resolve(`${packageName}/package.json`, { paths: [dir] }); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rtritto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
require.resolve
to locate dependencies regardless of whether PnP is used or not.