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:

.npmrc
enable-pre-post-scripts=true

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