Skip to content

Running npm ci doesn't install the node binary #88

@kohenkatz

Description

@kohenkatz

In order to make sure I am using the same dependencies, I usually run npm ci instead of npm install when I am working on my development machine (running Windows 10), unless I am specifically updating dependencies.

It seems that running npm ci does not install the node binaries, leading to errors.

It does create .\node_modules\.bin\node, .\node_modules\.bin\node.cmd, and .\node_modules\.bin\node.ps1 executable wrappers (for Bash, Command Prompt, and Powershell respectively), but those files point to the executable located at .\node_modules\node\bin\node, which is not present.

The two workarounds for this that I have found are:

  1. Manually delete the .\node_modules\node\ directory and the node executable wrappers (for all three shells) and run npm install node again.
  2. cd .\node_modules\node and run (PowerShell shown here) & 'C:\Program Files\nodejs\node.exe' .\installArchSpecificPackage.js

I'm not sure why the preinstall script doesn't seem to work when npm ci is used, but I do think it needs to be fixed.


Background:

Here is how I first found this problem:

  • npm install vuejs-datatable - this depends on core-js and therefore causes the core-js postinstall script to run. That postinstall script calls node -e ... which npm automatically redirects to call the local copy of node instead of the system copy.
    • Observe that the postinstall script runs without error.
  • Manually delete node_modules and run npm install
    • Observe that the postinstall script again runs with no error.
  • Run npm ci - this automatically deletes node_modules before it runs and then runs npm install making sure to use the exact package versions specified in package-lock.json.
    • Observe that the postinstall script of core-js now exits with an error The system cannot find the path specified.
    • Observe that this is true for any call to .\node_modules\.bin\node.cmd.
    • The error returned from the PowerShell version is more useful: The term 'C:\path\to\my\app\node_modules\.bin/../node/bin/node' is not recognized as the name of a cmdlet, function, script file, or operable program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions