{"record":{"id":"425b8c0694a6fe5e","repo":"handlebars-lang/handlebars.js","slug":"the-partial-options-name-could-not-be-compiled","errorCode":null,"errorMessage":"The partial ${options.name} could not be compiled when running in runtime-only mode","messagePattern":"The partial (.+?) could not be compiled when running in runtime-only mode","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"lib/handlebars/runtime.js","lineNumber":101,"sourceCode":"        env\n      );\n      result = options.partials[options.name](context, options);\n    }\n    if (result != null) {\n      if (options.indent) {\n        let lines = result.split('\\n');\n        for (let i = 0, l = lines.length; i < l; i++) {\n          if (!lines[i] && i + 1 === l) {\n            break;\n          }\n\n          lines[i] = options.indent + lines[i];\n        }\n        result = lines.join('\\n');\n      }\n      return result;\n    } else {\n      throw new Exception(\n        'The partial ' +\n          options.name +\n          ' could not be compiled when running in runtime-only mode'\n      );\n    }\n  }\n\n  // Just add water\n  let container = {\n    strict: function (obj, name, loc) {\n      if (obj == null || !(name in Object(obj))) {\n        throw new Exception('\"' + name + '\" not defined in ' + obj, {\n          loc: loc,\n        });\n      }\n      return container.lookupProperty(obj, name);\n    },\n    strictLookup: function (depths, name, loc) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/handlebars-lang/handlebars.js/blob/13a7a679910d2adbfe7f6fad61ce8f98426b0378/lib/handlebars/runtime.js#L83-L119","documentation":"Handlebars' runtime-only build (handlebars.runtime.js) cannot compile string partials; invokePartialWrapper throws when a partial resolves to a raw template string instead of a precompiled function. The full build compiles strings on the fly, but the runtime build omits the compiler. Only precompiled partial functions may be invoked in runtime-only mode.","triggerScenarios":"Registering a partial as a string (e.g. Handlebars.registerPartial('x', '<div>...</div>')) and then rendering with the runtime-only distribution (require('handlebars/runtime')).","commonSituations":"Bundlers (browserify/webpack) pulling in handlebars/runtime for smaller bundles; apps that register raw partial strings at runtime; migrating from full handlebars to the runtime build in Node.","solutions":["Precompile templates and partials with the handlebars CLI (handlebars templates/ -f compiled.js) so partials are functions","Use the full handlebars package instead of handlebars/runtime if strings must be compiled at runtime","Register partials as compiled template functions: Handlebars.template(require('./partial.hbs') or compiled source)"],"exampleFix":"// before\nconst Handlebars = require('handlebars/runtime');\nHandlebars.registerPartial('userCard', '<p>{{name}}</p>');\n\n// after\nconst Handlebars = require('handlebars/runtime');\nconst precompiled = require('./userCard.precompiled.js');\nHandlebars.registerPartial('userCard', Handlebars.template(precompiled));","handlingStrategy":"validation","validationCode":"function assertPrecompiledPartial(partial) {\n  if (typeof partial !== 'function') {\n    throw new Error('Partial must be a precompiled function when using handlebars/runtime');\n  }\n}\n// before registerPartial:\n// assertPrecompiledPartial(partial);","typeGuard":"function isCompiledPartial(p) {\n  return typeof p === 'function';\n}","tryCatchPattern":"try {\n  template(context);\n} catch (e) {\n  if (/runtime-only mode/.test(e.message)) {\n    // register precompiled partial or switch to full handlebars build\n  } else throw e;\n}","preventionTips":["Use handlebars/runtime only with precompiled (CLI-compiled) templates","Never register raw template strings when targeting the runtime build","Add a unit test that renders every template bundle with the runtime build","Pin which handlebars entry point the bundler resolves (alias full vs runtime)"],"tags":["handlebars","runtime","partials","precompilation"],"backgroundTag":"partial-not-precompiled","analyzedSha":"13a7a679910d2adbfe7f6fad61ce8f98426b0378","analyzedAt":"2026-09-02T20:25:07.518Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}