{"record":{"id":"8c1efeedac6047df","repo":"hyperledger/fabric","slug":"no-package-json-found-at-the-root-of-the-chaincode","errorCode":null,"errorMessage":"no package.json found at the root of the chaincode package","messagePattern":"no package\\.json found at the root of the chaincode package","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/node/platform.go","lineNumber":120,"sourceCode":"\t\t}\n\t\tif header.Name == \"src/package.json\" {\n\t\t\tfoundPackageJson = true\n\t\t}\n\t\t// --------------------------------------------------------------------------------------\n\t\t// Check that file mode makes sense\n\t\t// --------------------------------------------------------------------------------------\n\t\t// Acceptable flags:\n\t\t//      ISREG      == 0100000\n\t\t//      -rw-rw-rw- == 0666\n\t\t//\n\t\t// Anything else is suspect in this context and will be rejected\n\t\t// --------------------------------------------------------------------------------------\n\t\tif header.Mode&^0o100666 != 0 {\n\t\t\treturn fmt.Errorf(\"illegal file mode detected for file %s: %o\", header.Name, header.Mode)\n\t\t}\n\t}\n\tif !foundPackageJson {\n\t\treturn fmt.Errorf(\"no package.json found at the root of the chaincode package\")\n\t}\n\n\treturn nil\n}\n\n// Generates a deployment payload by putting source files in src/$file entries in .tar.gz format\nfunc (p *Platform) GetDeploymentPayload(path string) ([]byte, error) {\n\tvar err error\n\n\t// --------------------------------------------------------------------------------------\n\t// Write out our tar package\n\t// --------------------------------------------------------------------------------------\n\tpayload := bytes.NewBuffer(nil)\n\tgw := gzip.NewWriter(payload)\n\ttw := tar.NewWriter(gw)\n\n\tfolder := path\n\tif folder == \"\" {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/node/platform.go#L102-L138","documentation":"After scanning all tar headers, ValidateCodePackage requires that at least one entry was named exactly 'src/package.json'. If the Node.js chaincode payload never set foundPackageJson, the package is rejected because the platform cannot treat it as a valid Node.js chaincode project.","triggerScenarios":"ValidateCodePackage receives a .tar.gz with no entry at path 'src/package.json' — e.g. the manifest is at the archive root ('package.json'), in a nested folder, or missing entirely.","commonSituations":"Packaging the project directory instead of its src subfolder, renaming/moving package.json, using a build tool that flattens the layout, or packaging a non-Node project with the node platform type.","solutions":["Place package.json under a src/ directory in the project so it is packaged as 'src/package.json'.","Re-tar moving the manifest: create a src/ dir containing package.json and the code, then tar that.","Use the platform's GetDeploymentPayload with the chaincode path so packaging follows the required layout.","Confirm the chaincode type is 'node' — other platforms (Go, Java) have different manifest requirements."],"exampleFix":"// before (wrong layout in tar)\npackage.json\nmain.js\n// after (correct layout)\nsrc/package.json\nsrc/main.js","handlingStrategy":"validation","validationCode":"// list tar entries and verify manifest presence before submitting\nconst hasManifest = entries.some(e => e.name === 'src/package.json');","typeGuard":"function hasSrcPackageJson(entryNames) {\n  return Array.isArray(entryNames) && entryNames.includes('src/package.json');\n}","tryCatchPattern":null,"preventionTips":["Keep package.json in a src/ subdirectory of the chaincode project","Never rename or move package.json during builds","Use Fabric packaging commands to guarantee layout","Confirm chaincode language type matches the project layout"],"tags":["chaincode","packaging","validation","nodejs"],"backgroundTag":"missing-package-json","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}