Search code examples
npmdeno

Is there a way to introduce a preinstall step like the one in npm for installing deno packages in a deno project?


So npm allows a preinstall script to run before installing a module. For example, puppeteer uses this step to install headless chrome. Is there any way to do something like this with deno?


Solution

  • Unlike Node.js, Deno has no package manager. Instead of installing packages, all modules and dependencies are simply cached as static files for use at runtime — there is no configurable hook for an "installation step". Any code which requires an external dependency (such as a coordinating process in the case of Puppeteer) must ensure that such a dependency exists at runtime using program code. See Creating a Subprocess in the manual.

    See also section 3.1 of the manual Basics > Modules for information about the module system.


    For an example of a Puppeteer implementation in Deno, see https://deno.land/x/puppeteer (source GitHub repo).