Npm-check-updates: Directory permission error trying to upgrade package from 2.5.7 to 2.5.8

Created on 3 Feb 2016  ·  11Comments  ·  Source: raineorshine/npm-check-updates

I just tried upgrading from 2.5.7 to 2.5.8 and I got the following error from npm:

npm ERR! Refusing to delete /usr/local/bin/npm-check-updates: ../lib/node_modules/npm-check-updates/bin/old-alias symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/npm-check-updates

The full output from npm is below, and I can provide the npm-debug.log as well if more detail is needed

npm install -g npm-check-updates
/usr/local/bin/ncu -> /usr/local/lib/node_modules/npm-check-updates/bin/ncu
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone/node_modules/lodash._arraycopy
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone/node_modules/lodash._arrayeach
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone/node_modules/lodash._baseassign/node_modules/lodash._basecopy
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone/node_modules/lodash._baseassign
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone/node_modules/lodash._basefor
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.clonedeep/node_modules/lodash._baseclone
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.uniq/node_modules/lodash._basecallback/node_modules/lodash._baseisequal/node_modules/lodash.istypedarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.uniq/node_modules/lodash._basecallback/node_modules/lodash._baseisequal
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.uniq/node_modules/lodash._basecallback/node_modules/lodash.pairs
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.uniq/node_modules/lodash._basecallback
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.uniq/node_modules/lodash._isiterateecall
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/lodash.without/node_modules/lodash._basedifference
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/ansi
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/are-we-there-yet
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog/node_modules/gauge
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-install-checks/node_modules/npmlog
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/process-nextick-args
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/util-deprecate
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/util-deprecate
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/bl/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/node_modules/assert-plus
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream/node_modules/core-util-is
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream/node_modules/isarray
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream/node_modules/process-nextick-args
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream/node_modules/string_decoder
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream/node_modules/util-deprecate
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/sha/node_modules/readable-stream
- [email protected] node_modules/npm-check-updates/node_modules/npm/node_modules/validate-npm-package-license/node_modules/spdx-license-ids
/usr/local/lib
└── (empty)

npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/Cellar/node/5.5.0/bin/node" "/usr/local/bin/npm" "install" "-g" "npm-check-updates"
npm ERR! node v5.5.0
npm ERR! npm  v3.5.3
npm ERR! path /usr/local/bin/npm-check-updates
npm ERR! code EEXIST

npm ERR! Refusing to delete /usr/local/bin/npm-check-updates: ../lib/node_modules/npm-check-updates/bin/old-alias symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/npm-check-updates
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/username/Source/reduxboard/npm-debug.log
npm ERR! code 1
Usernames-MacBook-Pro:reduxboard username$ npm install -g npm-check-updates
/usr/local/bin/ncu -> /usr/local/lib/node_modules/npm-check-updates/bin/ncu
/usr/local/lib
└── (empty)

npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/Cellar/node/5.5.0/bin/node" "/usr/local/bin/npm" "install" "-g" "npm-check-updates"
npm ERR! node v5.5.0
npm ERR! npm  v3.5.3
npm ERR! path /usr/local/bin/npm-check-updates
npm ERR! code EEXIST

npm ERR! Refusing to delete /usr/local/bin/npm-check-updates: ../lib/node_modules/npm-check-updates/bin/old-alias symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/npm-check-updates
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/username/Source/reduxboard/npm-debug.log
npm ERR! code 1
faq

Most helpful comment

I was able to resolve the issue by manually deleting the previous npm-check-updates file before running the install:

rm /usr/local/bin/npm-check-updates
npm install -g npm-check-updates

Looks like there's a glitch when installing version 2.5.8 over version 2.5.7 where the old npm-check-updates file is not being correctly cleaned up before the new one is created

All 11 comments

@justinhelmer Looks like an unintended consequence of your pull request. Is there a fix or should we revert?

@jharris4 @metaraine

I just spun up a fresh VM and tried the global install; everything seemed ok.

By reading through the output, it looks to me like a permissions issue. npm seems to be trying to delete the old bin, but is yelling at you. It is possible I'm interpreting the output incorrectly, or it is possible this is related to how you installed node.

I know some people require sudo for using -g; should be a thing of the past, but possibly related.

For now, let's move forward assuming this is an isolated issue. Try:

$ sudo npm uninstall -g npm-check-updates
$ npm cache clean
$ npm install -g npm-check-updates # may require sudo, but try without it first

If that doesn't work, we can go from there. But it just needs that old bin to go away.

I just dug up an old box that had an _archaic_ version of npm-check-updates (I was an early subscriber ;-) ) and was running Node 0.8.

I blew away the dust, installed nvm to get node up to 0.12.x (the current minimum requirement to use this module), and did one thing:

$ npm install -g npm-check-updates

Everything worked like a charm.

@jharris4 - We are still more than happy to help you through this; however @metaraine I believe you should be comfortable re-labeling this issue (not likely a bug ).

Thank you for troubleshooting @justinhelmer!

I was able to resolve the issue by manually deleting the previous npm-check-updates file before running the install:

rm /usr/local/bin/npm-check-updates
npm install -g npm-check-updates

Looks like there's a glitch when installing version 2.5.8 over version 2.5.7 where the old npm-check-updates file is not being correctly cleaned up before the new one is created

@jharris4 - Personally, I prefer to install node and npm separately, i.e.:

# skipping npm so we can install it with custom configuration
brew install node012 --without-npm 
brew link node012 &>/dev/null

# install npm, and configure it to install global node modules in the home dir
# (so we dont have to sudo for global node modules)
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

You may have success with avoiding this type of thing in the future for globally-installed npm modules that require deleting existing files during the process of an update.

Personally, this method has worked well for me.

@metaraine - I think we can safely wrap this one up.

That's a good suggestion in this case, but given that the vast majority of developers will be installing node that comes package with npm, we want to ensure npm-check-updates works seamlessly for that configuration.

I'll close this for now. Thanks!

Agreed. I'll keep my eye out if you tag me on another issue.

Cheers

I had the same problem updating from version 2.5.6 to 2.5.8. I was using node version 5.6.0 and npm version 3.6.0.

I have node installed from homebrew bundled with npm.

Following @jharris4 workaround solved the issue.

If anyone has any suggestions on how to prevent this for future consumers who are upgrading from an older version of ncu, we are happy to make the consideration.

I just ran into a similar issue. I Installed a new version of node (v6) with NVM then migrated the global npm modules from v5 with nvm reinstall-packages v5, and later tried to install a new version of ncu.

I had to delete the migrated bin first:
rm /Users/me/.nvm/versions/node/v6.0.0/bin/npm-check-updates

This was the error:

npm ERR! Darwin 15.3.0
npm ERR! argv "/Users/me/.nvm/versions/node/v6.0.0/bin/node" "/Users/me/.nvm/versions/node/v6.0.0/bin/npm" "install" "-g" "npm-check-updates"
npm ERR! node v6.0.0
npm ERR! npm  v3.8.6
npm ERR! path /Users/me/.nvm/versions/node/v6.0.0/bin/npm-check-updates
npm ERR! code EEXIST

npm ERR! Refusing to delete /Users/me/.nvm/versions/node/v6.0.0/bin/npm-check-updates: ../lib/node_modules/npm-check-updates/bin/old-alias symlink target is not controlled by npm /Users/me/.nvm/versions/node/v6.0.0
npm ERR! File exists: /Users/me/.nvm/versions/node/v6.0.0/bin/npm-check-updates
npm ERR! Move it away, and try again.
Was this page helpful?
0 / 5 - 0 ratings