You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on my experiments, we will not be using findPackageJSON in its current state. It's too particular about the input and the documentation does not reflect the actual implementation. Examples:
❌ Find package.json based on package specifier alone:
> findPackageJSON("react-native")
Uncaught TypeError: Invalid URL
at getPackageScopeConfig (node:internal/modules/package_json_reader:208:33)
at getPackageJSONURL (node:internal/modules/package_json_reader:284:25)
at Function.findPackageJSON (node:internal/modules/package_json_reader:341:33) {
code: 'ERR_INVALID_URL',
input: './package.json',
base: 'data:'
}
❌ Find package.json based on package specifier and base directory:
> findPackageJSON("react-native", process.cwd())
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react-native' imported from /~/packages/test-app
at getPackageJSONURL (node:internal/modules/package_json_reader:314:9)
at Function.findPackageJSON (node:internal/modules/package_json_reader:341:33) {
code: 'ERR_MODULE_NOT_FOUND'
}
✅ Find package.json based on package specifier and file in base directory:
❌ Find package.json based on absolute path to package:
> findPackageJSON(require.resolve("react-native"))
Uncaught:
TypeError [ERR_UNSUPPORTED_RESOLVE_REQUEST]: Failed to resolve module specifier "/~/node_modules/.store/react-native-virtual-4431a9491c/package/index.js" from "data:": Invalid relative URL or base scheme is not hierarchical.
at moduleResolve (node:internal/modules/esm/resolve:839:21)
at defaultResolve (node:internal/modules/esm/resolve:985:11)
at Function.findPackageJSON (node:internal/modules/package_json_reader:354:22) {
code: 'ERR_UNSUPPORTED_RESOLVE_REQUEST',
cause: TypeError: Invalid URL
at new URL (node:internal/url:818:25)
at moduleResolve (node:internal/modules/esm/resolve:837:18)
at defaultResolve (node:internal/modules/esm/resolve:985:11)
at Function.findPackageJSON (node:internal/modules/package_json_reader:354:22)
at REPL35:1:24
at ContextifyScript.runInThisContext (node:vm:137:12)
at REPLServer.defaultEval (node:repl:593:22)
at bound (node:domain:433:15)
at REPLServer.runBound [as eval] (node:domain:444:12)
at REPLServer.onLine (node:repl:926:10) {
code: 'ERR_INVALID_URL',
input: '/~/node_modules/.store/react-native-virtual-4431a9491c/package/index.js',
base: 'data:'
}
}
❌ Find package.json based on absolute path to package and empty base:
> findPackageJSON(require.resolve("react-native"), "")
Uncaught TypeError: Invalid URL
at new URL (node:internal/url:818:25)
at Function.findPackageJSON (node:internal/modules/package_json_reader:336:63) {
code: 'ERR_INVALID_URL',
input: ''
}
✅ Find package.json based on absolute path to package and base directory:
Activity
tido64 commentedon May 12, 2026
Based on my experiments, we will not be using
findPackageJSONin its current state. It's too particular about the input and the documentation does not reflect the actual implementation. Examples:❌ Find
package.jsonbased on package specifier alone:❌ Find
package.jsonbased on package specifier and base directory:✅ Find
package.jsonbased on package specifier and file in base directory:❌ Find
package.jsonbased on absolute path to package:❌ Find
package.jsonbased on absolute path to package and empty base:✅ Find
package.jsonbased on absolute path to package and base directory: