haraka / node-address-rfc2821

RFC2821 Email Address parser (from Haraka)
https://www.npmjs.com/package/address-rfc2821
13 stars 6 forks source link

Generating parser in postinstall triggering nearley installation #46

Closed moshen closed 1 year ago

moshen commented 1 year ago

The postinstall script in package.json: https://github.com/haraka/node-address-rfc2821/blob/57c9347226dbd4f3b8d3d97c6651d346fb3348bc/package.json#L33

Is triggering a nearley package install in our systems during the bootstrap phase of our repo. I'm not exactly sure why, as the nearley package should already exist. This only appeared after upgrading Haraka to the latest version. For us this breaks things (probably because of locking down npm installs).

I thought I would log this as an issue as others may have run into it.

If you add the --no-install flag (or simply --no for npm >= 7, though --no-install still works), the local nearley should be used.

Alternatively, postinstall scripts are generally best avoided unless absolutely required. The grammar generation could be moved into a prepack or pretest script. Looking at other examples of nearley it looks like it still needs to be a dependency, but generating the js at build time seems acceptable.

msimerson commented 1 year ago

Alternatively, postinstall scripts are generally best avoided unless absolutely required. The grammar generation could be moved into a prepack or pretest script. Looking at other examples of nearley it looks like it still needs to be a dependency, but generating the js at build time seems acceptable.

This is probably the best idea. I've ceased using nearly in other projects due to its lack of maintenance and inability to install in some environments.