diff --git a/python/pminit/post-install-hook.py b/python/pminit/post-install-hook.py index 52f1e423..1b2d26dd 100644 --- a/python/pminit/post-install-hook.py +++ b/python/pminit/post-install-hook.py @@ -1,5 +1,6 @@ import subprocess import sys +import shutil def execute(cmd: str): popen = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, @@ -14,7 +15,25 @@ def execute(cmd: str): raise subprocess.CalledProcessError(return_code, cmd) def main(): - execute("cd pythonmonkey && npm i --no-package-lock") # do not update package-lock.json + node_package_manager = 'npm' + # check if npm is installed on the system + if (shutil.which(node_package_manager) is None): + print(""" + +PythonMonkey Build Error: + + + * It appears npm is not installed on this system. + * npm is required for PythonMonkey to build. + * Please install NPM and Node.js before installing PythonMonkey. + * Refer to the documentation for installing NPM and Node.js here: https://nodejs.org/en/download + + + """) + raise Exception("PythonMonkey build error: Unable to find npm on the system.") + else: + execute(f"cd pythonmonkey && {node_package_manager} i --no-package-lock") # do not update package-lock.json if __name__ == "__main__": main() +