{"record":{"id":"c3ce507728ff447c","repo":"theonedev/onedev","slug":"package-management-not-enabled-for-project","errorCode":null,"errorMessage":"Package management not enabled for project ''","messagePattern":"Package management not enabled for project ''","errorType":"http","errorClass":"ClientException","httpStatus":406,"severity":"error","filePath":"server-plugin/server-plugin-pack-npm/src/main/java/io/onedev/server/plugin/pack/npm/NpmPackHandler.java","lineNumber":581,"sourceCode":"\t\t\t\t\tthrow new ClientException(SC_BAD_REQUEST, \"Invalid request path\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getApiKey(HttpServletRequest request) {\n\t\tvar authzHeader = request.getHeader(HttpHeaders.AUTHORIZATION);\n\t\tif (authzHeader != null&& authzHeader.toLowerCase().startsWith(\"bearer \")) \n\t\t\treturn StringUtils.substringAfter(authzHeader, \" \");\n\t\telse\n\t\t\treturn null;\n\t}\n\n\tprivate Project checkProject(Long projectId, boolean needsToWrite) {\n\t\tvar project = projectService.load(projectId);\n\t\tif (!project.isPackManagement())\n\t\t\tthrow new ClientException(SC_NOT_ACCEPTABLE, \"Package management not enabled for project '\" + project.getPath() + \"'\");\n\t\telse if (needsToWrite && !SecurityUtils.canWritePack(project))\n\t\t\tthrow new UnauthorizedException(\"No package write permission for project: \" + project.getPath());\n\t\telse if (!needsToWrite && !SecurityUtils.canReadPack(project))\n\t\t\tthrow new UnauthorizedException(\"No package read permission for project: \" + project.getPath());\n\t\treturn project;\n\t}\n\t\n\t@Override\n\tpublic List<String> normalize(List<String> pathSegments) {\n\t\treturn pathSegments;\n\t}\n\n}\n","sourceCodeStart":563,"sourceCodeEnd":595,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-npm/src/main/java/io/onedev/server/plugin/pack/npm/NpmPackHandler.java#L563-L595","documentation":"Thrown by checkProject before any npm registry operation when the target project does not have Package Management enabled. OneDev returns HTTP 406 (Not Acceptable) with the project path in the message, so npm clients see a 406 during publish, metadata fetch, or tarball download.","triggerScenarios":"Any npm request (publish, metadata, tarball) whose projectId resolves to a project where project.isPackManagement() is false — checkProject runs inside every routed operation.","commonSituations":"Pointing .npmrc at a OneDev project created before enabling packages; moving the registry to a different project that lacks the feature; project settings reset or feature disabled by an admin.","solutions":["Enable Package Management in the project: Project -> Packages (or Administration/Project settings) -> enable package management.","Confirm the registry URL references the intended project path that has package management enabled.","If the project was recently renamed/moved, update .npmrc to the new project path."],"exampleFix":"// before (.npmrc) — project without packages\nregistry=https://onedev.example.com/npm/plain-project/\n// after — enable packages on 'proj' first\nregistry=https://onedev.example.com/npm/proj/","handlingStrategy":"validation","validationCode":"// Check via API that the project has package management before using npm registry\nconst resp = await fetch(`${onedevUrl}/~api/projects/${encodePath(projectPath)}`, { headers: auth });\nconst project = await resp.json();\nif (!project.packManagement) throw new Error(`Enable package management on ${projectPath} first`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable Package Management on the project before configuring .npmrc.","Point the registry at the project that actually hosts packages.","Re-check settings after project renames or migrations."],"tags":["npm","http-406","feature-disabled"],"backgroundTag":"feature-not-enabled","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}