greenkeeperio / greenkeeper-lockfile

:lock: Your lockfile, up to date, all the time
https://greenkeeper.io
183 stars 73 forks source link

Consider --force option when reinstalling package #112

Open Comandeer opened 6 years ago

Comandeer commented 6 years ago

Current version of updateLockFile function calls npm install without --force flag. Such method fails when package is a dev-dependency of itself (e.g. bundler, which bundles itself; it's the case with rollup and my project, in which I encountered this issue):

Travis CI log Error: Command failed: npm install -D --save-prefix="^" @comandeer/rollup-lib-bundler@0.4.0 npm ERR! code ENOSELF npm ERR! Refusing to install package with name "@comandeer/rollup-lib-bundler" under a package npm ERR! also called "@comandeer/rollup-lib-bundler". Did you name your project the same npm ERR! as the dependency you're installing? npm ERR! npm ERR! For more information, see: npm ERR! npm ERR! A complete log of this run can be found in: npm ERR! /home/travis/.npm/_logs/2018-02-03T21_18_40_904Z-debug.log at checkExecSyncError (child_process.js:601:13) at execSync (child_process.js:641:13) at updateLockfile (/home/travis/.nvm/versions/node/v8.9.4/lib/node_modules/greenkeeper-lockfile/lib/update-lockfile.js:44:7) at Module.update [as exports] (/home/travis/.nvm/versions/node/v8.9.4/lib/node_modules/greenkeeper-lockfile/update.js:54:3) at Object. (/home/travis/.nvm/versions/node/v8.9.4/lib/node_modules/greenkeeper-lockfile/update.js:62:37) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3)

Addition of --force flag should be enough. It also should be safe in this context as greenkeeper just reinstalls already installed package.