# Private npm help

**URL:** <https://community.directus.com/t/private-npm-help/1480>\
**Category:** Help\
**Tags:** extensions\
**Created:** [November 10, 2025, 7:43pm UTC](https://community.directus.com/t/private-npm-help/1480 "2025-11-10T19:43:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel\_Soong](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/noel_soong/32/160_2.png) [@Noel\_Soong](https://community.directus.com/u/Noel_Soong)\
**Post date:** [November 10, 2025, 7:43pm UTC](https://community.directus.com/t/private-npm-help/1480/1 "2025-11-10T19:43:48Z")

</div>

Hi i published a library in github npm registry to be used for extensions. However when I tried putting .npmrc file with the correct secret into a custom dockerfile for directus I can’t get it to work. Should it be in the root directory for directus?

`/directus` directory?

---

<div class="post-metadata">

**Author:** ![Noel\_Soong](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/noel_soong/32/160_2.png) [@Noel\_Soong](https://community.directus.com/u/Noel_Soong)\
**Post date:** [November 10, 2025, 9:57pm UTC](https://community.directus.com/t/private-npm-help/1480/2 "2025-11-10T21:57:33Z")

</div>

something like this

```dockerfile
# --- Build Stage ---
FROM directus/directus:11.12.0 AS build 
WORKDIR /directus

# Switch to root to install pnpm, as it's used by Directus internally
USER root
RUN npm install -g pnpm

# Switch back to the node user (default user in directus image)
USER node

# Copy package.json and .npmrc
COPY package.json .npmrc ./

# Install dependencies using build secret for secure access to the private registry
# The --secret flag requires BuildKit to be enabled
RUN --mount=type=secret,id=npmrc,dst=.npmrc pnpm install --prod

# Remove the .npmrc file after installation for security
RUN rm -f .npmrc

# Copy the rest of your application files, including extensions
COPY . .

# If you have custom extensions built, ensure they are compiled or copied correctly.
# The `pnpm install` above should handle installing the extension dependencies.

# --- Final Stage (Optional but Recommended for a cleaner final image) ---
# Use a fresh Directus image and copy only necessary files from the build stage
FROM directus/directus:11.12.0
WORKDIR /directus

# Copy installed node_modules and other project files from the build stage
COPY --from=build /directus/node_modules ./node_modules
COPY --from=build /directus/package.json ./package.json
COPY --from=build /directus/src ./src
COPY --from=build /directus/extensions ./extensions
COPY --from=build /directus/uploads ./uploads
# Copy other necessary files/folders like public, etc.

# Expose port and start Directus (default behavior of directus/directus image)
EXPOSE 8055
CMD ["directus", "start"]

```
