How to fix "postbuild" and "prebuild" not working with pnpm?


When recently working on my blog, I tried to add a postbuild scripts with next-sitemap in my package.json. My goal was to automatically generate .xml files after each Next.js builds.

Using pnpm, I found out that my postbuild was working with npm but not pnpm.

I found out this issue on Github mentionning the same problem I encountered. It seems that pre/posts scripts are not activated if using pnpm.

I found the solution adding the line below in my .npmrc local file:


Now I can use pre/posts scripts and pnpm. I hope this could save you some time!

Has this been helpful to you?
You can support my work by sharing this article with others,
sponsoring me on Github or perhaps buy me a cup of coffee 😊


Share your thoughts! If you don't have a Github account, you can tweet it!