It looks like npm is not able to replace the npm script when it is in use. I couldn’t reproduce this locally and find the root cause, but it happens every time on Travis.
Not using the script works:
node `npm prefix -g`/node_modules/npm/bin/npm-cli.js i -g npm@latest
Alternatively, setting a different global prefix also works:
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export NPM_CONFIG_PREFIX=c:\\npm_prefix PATH="/c/npm_prefix:$PATH"; fi
At first I suspected nvs was run as Administrator, but confirmed this is not the case and the permissions of the nvs folder are correct.