The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Modifying a Project's package.json
I’m trying to add a
postbuild script to the project that installed my module. It works when manually added, but I’d prefer it happen automatically after my module has been installed.
From what I understand, I need to add a
postinstall entry in my module’s
package.json pointing to a file like
"postinstall": "node src/postinstall.js". But from there I’m at a loss how to modify the top level project’s
package.json. Any help would be appreciated.
I would caution again modifying the top-level
package.json as part of the installation of a dependency if you intend for this package to be used by other people. I do not expect or want packages to be mucking with my
package.json when I install them. You could add a command to offer this in an explicit way say:
$ npx your-module setup-wizard This will add a postinstall script to your package, and [some other stuff] Do you want to continue? (Y/n)
I managed to figure it out, but I like your suggestion of using a setup wizard.