0

TLDR: How reliable is an assumption that a compatible version of make is installed on machines that my NPM package will be installed on?

I'm working for a client who is really fond of make and Makefiles. We need to integrate a JS package into another project. My go-to method would be npm install our-package. The package requires a build step. We want to be able to install versions that are not yet released to npm.js from GitHub. The build process is more than one line of shell script so I don't want to repeat it in Makefile and in package.json (it will go out of sync real quick). Straight forward way is to set scrpits.prepare to make in packgae.json. But I'm concerned about cross-platform compatibility (Windows, containers, etc).

Update: I've also discovered that it's extremely easy to create an endless loop where make calls npm ci or npm install and then npm calls make. With npm install there is --ignore-scripts option, but ci doesn't have an equivalent, see: https://npm.community/t/add-ignore-scripts-option-to-clean-install-ci-command/6322

Tad Lispy
  • 2,806
  • 3
  • 30
  • 31
  • 1
    Windows machines usually don't have `make` at all. I don't think there could be a good advice here. – Matt Mar 21 '19 at 10:43
  • 1
    On older mac OSX you [had to install Xcode](https://stackoverflow.com/questions/6767481/where-can-i-find-make-program-for-mac-os-x-lion#answer-6767528) to get command-line tools such as `make`. – RobC Mar 21 '19 at 12:29
  • 1
    IMHO in npm environment `make` is not a good choice. Have you considered to describe the build step via [Gulp](https://gulpjs.com/) or [Grunt](https://gruntjs.com/)? Then you would list one of them as dependency in `package.json` and set `scripts.prepare` to call the tool. You could call that same tool from a `Makefile` recipe (if I understand your requirement for `make` correctly). – Stefan Becker Mar 22 '19 at 05:58
  • Personally I agree with you @StefanBecker. Actually I use Parcel which just does all the magic with almost no configuration. As I've mentioned, it's the client's strong preference to have build described in Makefile. They are back-end oriented. I don't think simply calling another tool chain from make would satisfy them. It would be a little bit of "cheating" and they are too smart for that. +1 anyway :-) – Tad Lispy Mar 22 '19 at 06:28
  • 1
    Does the client understand that by requiring a `Makefile` the npm module can only be installed of machines that have `make`? Maybe that is an acceptable restriction for them. I would then suggest to add a check that `make` can be found and print out a clear error message if it is missing. – Stefan Becker Mar 22 '19 at 07:28

0 Answers0