Azure / meta-azure-service-broker

A service broker to manage multiple Azure services in Cloud Foundry
Apache License 2.0
39 stars 44 forks source link

Invalid .npmrc confi causes ENOTCACHED error #207

Open IObert opened 5 years ago

IObert commented 5 years ago

Hi,

I noticed that the line offline=true in the .npmrc file causes the following error (on two distinct machines):

C02W10MUHTD8:meta-azure-service-broker ----$ npm install
npm ERR! code ENOTCACHED
npm ERR! request to https://registry.npmjs.org/async failed: cache mode is 'only-if-cached' but no cached response available.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/-----/.npm/_logs/2019-02-15T10_31_33_339Z-debug.log

It works fine when I remove the line (I noticed that this line has been added because of #199 but I didn't encounter that problem)

zhongyi-zhang commented 5 years ago

199 only occurs in CF envs which don't allow to access npm registry. It does need offline=true in .npmrc to be pushed to CF. So it is a dilemma for the broker...… (Not like golang, nodejs doesn't keep vendors in the repo.) Yeah you can just delete it and run npm install. Or, a tricky way is to downgrade npm to 3.x (because older npm doesn't read project-level .npmrc, but your CF still knows it). Sorry for the inconvenience...

kevinhillinger commented 4 years ago

Per the documentation here, the better option is prefer-offline=true. Otherwise as is noted by @IObert, when building the service broker app, you must do the following on the bosh VM:

sudo npm install --offline=false --unsafe-perm=true --allow-root
rm ./package-lock.json

This forces the initial installation of all dependencies, which then allows the cf push to work.

If a CF environment doesn't have access to NPM repo, the issue is mute if we choose prefer-offline=true as the solution, since a pre-loaded node_modules will exist for those not able to pull them, and for those who don't have an issue accessing NPM repo, it will pull.