{"record":{"id":"29e6874b616cd373","repo":"parcel-bundler/parcel","slug":"could-not-resolve-module-id-from-from","errorCode":null,"errorMessage":"Could not resolve module \"${id}\" from \"${from}\"","messagePattern":"Could not resolve module \"(.+?)\" from \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/packagers/react-static/src/ReactStaticPackager.js","lineNumber":571,"sourceCode":"    } else {\n      throw new Error('Bundle not found');\n    }\n  };\n\n  // No-op. We can access the bundle graph directly.\n  parcelRequire.extendImportMap = () => {};\n\n  // Resolve and load a module by specifier.\n  let loadModule = (id: string, from: string, env = 'react-client') => {\n    let resolver = env === 'react-server' ? serverResolver : clientResolver;\n    let res = resolver.resolve({\n      filename: id,\n      specifierType: 'commonjs',\n      parent: from,\n    });\n\n    if (res.error) {\n      throw new Error(`Could not resolve module \"${id}\" from \"${from}\"`);\n    }\n\n    let defaultRequire = Module.createRequire(from);\n    let resolution = res.resolution;\n    if (resolution.type === 'Builtin') {\n      let {scheme, module} = resolution.value;\n      return defaultRequire(scheme ? `${scheme}:${module}` : module);\n    }\n\n    if (resolution.type === 'Path') {\n      let cacheKey = resolution.value + '#' + env;\n      const cachedModule = moduleCache.get(cacheKey);\n      if (cachedModule) {\n        return cachedModule.exports;\n      }\n\n      let assetId = assetsByFilePath.get(cacheKey);\n      if (assetId) {","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/packagers/react-static/src/ReactStaticPackager.js#L553-L589","documentation":"Thrown by ReactStaticPackager.loadModule during React Server Components / static (SSG) rendering. Parcel evaluates bundle code in a VM context at build time and resolves every specifier through @parcel/node-resolver-core (a server resolver for 'react-server' env, a client resolver otherwise). When resolver.resolve returns an error object (not an exception) for the given id/parent pair, the packager converts it into this thrown Error. It means Node-style module resolution failed inside the SSR/SSG sandbox.","triggerScenarios":"A bundle evaluated by the react-static packager requires/import a specifier that the configured NodeResolver cannot resolve. Calls into loadModule happen transitively via the `require` shim that runModule injects, so any require() executed during RSC rendering of a module walks here. resolution.error is set when the file is missing, the package is not installed, or an `exports`/`browser` map excludes it for the given env.","commonSituations":"Importing a Node-only or browser-only package from a 'react-server' module that the serverResolver cannot map; missing dependency in node_modules after an incomplete install; typo'd relative specifier in code only reachable during SSG/RSC evaluation; a package whose package.json `exports` field restricts the requested condition (e.g. no `react-server` export); symlinks/monorepo hoisting causing the resolver to look in the wrong node_modules.","solutions":["Run the build with PARCEL_LOG_LEVEL=verbose (or --log-level verbose) and check the prior resolver diagnostics to see which specifier and parent file are involved.","Confirm the named package is resolvable from the `from` path: run `node -e \"console.log(require.resolve('${id}', {paths:['${from}']}))\"` from the project root.","If the package is missing, install it as a real dependency (`npm i <pkg>`); do not rely on a transitive dep that can be hoisted away.","If the package exists but is excluded by `exports`, add the matching condition to your target env or add an explicit `react-server`/`import` export in the dependency's package.json.","For relative specifiers, verify the file extension (Parcel matches the literal specifier) and that the path is correct relative to `from`.","For monorepos, ensure the package is resolvable from the specific workspace that owns the failing source file; check hoisting in pnpm (use public-hoist-pattern or node-linker if needed)."],"exampleFix":"// before (in a react-server module)\nimport {render} from 'some-node-lib';\n// resolver fails because 'some-node-lib' has no react-server-compatible export\n\n// after: add the export condition or alias, OR ensure the package is installed\n// package.json of some-node-lib\n\"exports\": {\n  \".\": {\n    \"react-server\": \"./index.server.js\",\n    \"default\": \"./index.js\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Pre-flight resolve check before running an RSC/SSG build\nconst {create} = require('@parcel/node-resolver-core');\nasync function assertResolvable(specifier, fromPath, env = 'react-server') {\n  const resolver = create({fs: require('fs'), projectRoot: process.cwd()});\n  const res = await resolver.resolve({\n    filename: specifier,\n    specifierType: 'commonjs',\n    parent: fromPath,\n  });\n  if (res.error) {\n    throw new Error(`Pre-build check failed: ${specifier} from ${fromPath} (${res.error})`);\n  }\n  return res.resolution;\n}","typeGuard":null,"tryCatchPattern":"// Wrap your build entrypoint\ntry {\n  await runRSCBuild();\n} catch (err) {\n  if (/Could not resolve module/.test(err.message)) {\n    const m = err.message.match(/\"([^\"]+)\" from \"([^\"]+)\"/);\n    console.error(`[build] missing dependency: ${m?.[1]} (from ${m?.[2]})`);\n    process.exitCode = 2;\n  } else {\n    throw err;\n  }\n}","preventionTips":["Keep a single source of truth for dependencies in package.json and run `npm ls` in CI to catch missing packages.","Pin projectRoot explicitly via CLI --dist-dir/--config so resolver parent paths are deterministic.","For monorepos, validate that every package imported by RSC entry points is resolvable from the workspace that owns the entry."],"tags":["rsc","ssr","module-resolution","react-static","build-time"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}