Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kohenkatz opened this issue Jan 23, 2020 · 4 comments
Open

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

kohenkatz opened this issue Jan 23, 2020 · 4 comments

Comments

@kohenkatz
Copy link

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.
@aredridel
Copy link
Owner

Aye. I expect this is a tough dependency-ordering problem. There's no guarantee in which order postinstall scripts run.

@aredridel
Copy link
Owner

It's likely to work if the architecture-specific package is depended upon, but then the app loses portability.

@kohenkatz
Copy link
Author

The thing I am still trying to figure out is why there is a difference between npm intall and npm ci. I would think that they should both work the same way.

@aredridel
Copy link
Owner

It may be an installation order problem. ci can take shortcuts that install cannot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants