Monday, 5 January 2015

update yeoman, update npm

When I use yeoman to generate angular project today, I found the error on the top of above picture.


1
2
3
4
5
6
7
8
9
10
11
npm ERR! Error: ENOENT, lstat '/Users/peterwang/Documents/dev/code/xx/node_modules/grunt/node_modules/lodash/lodash.underscore.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/peterwang/Documents/dev/code/xx
npm ERR! node -v v0.10.34
npm ERR! npm -v 1.4.28
npm ERR! path /Users/peterwang/Documents/dev/code/xx/node_modules/grunt/node_modules/lodash/lodash.underscore.js
npm ERR! fstream_path /Users/peterwang/Documents/dev/code/xx/node_modules/grunt/node_modules/lodash/lodash.underscore.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:287:26
npm ERR! fstream_stack Objec
....
....
....
....
.
.
.
.
pre-build test passed successfully!
npm ERR! Error: ENOTEMPTY, rmdir '/Users/peterwang/Documents/dev/code/xx/node_modules/grunt/node_modules/js-yaml/examples'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "karma-phantomjs-launcher" "karma-jasmine" "grunt-karma" "--save-dev"
npm ERR! cwd /Users/peterwang/Documents/dev/code/xx
npm ERR! node -v v0.10.34
npm ERR! npm -v 1.4.28
npm ERR! path /Users/peterwang/Documents/dev/code/xx/node_modules/grunt/node_modules/js-yaml/examples
npm ERR! code ENOTEMPTY
npm ERR! errno 53
npm ERR! not ok code 0
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/peterwang/Documents/dev/code/xx/npm-debug.log
npm ERR! not ok code 0
app/index.html modified.


     _-----_
    |       |    .---------------------------------------.
    |--(o)--|    |        Bye from us! Chat soon.        |
   `---------´   |                                       |
    ( _´U`_ )    |            The Yeoman Team            |
    /___A___\    | https://github.com/yeoman/yeoman#team |
     |  ~  |     '---------------------------------------'
   __'.___.'__   
 ´   `  |° ´ Y




I found my
npm version is 1.4.28.
yo version is 1.3.3
node is v0.10.34


so i tried to upgrade my npm by:

1
2
3
4
5
6
7
8
9
10
11
npm install npm -g 


even

1
2
3
4
5
6
7
8
9
10
11
sodu npm install npm -g 

I got this error:


1
2
3
4
5
11
Peter:MTOcurtains peterwang$ npm install npm -g 
npm ERR! Refusing to delete: /usr/local/share/man/man1/npm-bugs.1 not in /usr/local/lib/node_modules/npm
File exists: /usr/local/share/man/man1/npm-bugs.1
Move it away, and try again. 

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "-g"
npm ERR! cwd /Users/peterwang/Documents/dev/code/xxxxx
npm ERR! node -v v0.10.34
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/share/man/man1/npm-bugs.1
npm ERR! code EEXIST
npm ERR! error rolling back Error: Refusing to delete: /usr/local/share/man/man1/npm-README.1 not in /usr/local/lib/node_modules/npm
npm ERR! error rolling back     at clobberFail (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:57:12)
npm ERR! error rolling back     at next (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:43:14)
npm ERR! error rolling back     at /usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:52:12
npm ERR! error rolling back     at Object.oncomplete (evalmachine.<anonymous>:108:15)
npm ERR! error rolling back  { [Error: Refusing to delete: /usr/local/share/man/man1/npm-README.1 not in /usr/local/lib/node_modules/npm]
npm ERR! error rolling back   code: 'EEXIST',
npm ERR! error rolling back   path: '/usr/local/share/man/man1/npm-README.1' }
npm ERR! not ok code 0



so I delete this file "npm-README.1" and rerun the update command. The error doesn't really change because it mention another file is exist.


Cause

npm no longer enforces that man pages have to have the prefix of their package name. This is actually a lot smarter, and lets you, for example, have a package named blerg-llama that deploys a bin named blhave man bl actually tell you about the bl command. And, finally, we can have man 5 package.json, which I've wanted forever.
However, npm 1.3.2 and before did have this restriction, so the man page for bl would have been installed as blerg-llama-bl.1 instead. This results in some oddness when installing npm, which I didn't catch, because I usually use npm to install itself, rather than using an older version to install the newer one.
So, using npm@1.3.2 to install npm@1.3.4 will work now. However, you'll have some man pages like/usr/local/share/man/man5/npm-package.json.5, instead of the intended/usr/local/share/man/man5/package.json.5 file, without the npm- on the front.

Solution

Run this command to find any and all installed man pages that npm has put on your system:
find /usr/local/share/man -ls | grep npm | awk '{print $11}'
If you want to delete those, you can quite easily by doing this:
find /usr/local/share/man -ls | grep npm | awk '{print $11}' | xargs rm
If you do your global npm installs as root using sudo, then you'll need to sudo the rm, as well. Pleasedefinitely inspect the list before running this command, so you don't rm something that you wish you hadn't!
# be careful, this is really dangerous!
find /usr/local/share/man -ls | grep npm | awk '{print $11}' | xargs sudo rm
Once you do that, if you want to put back just the correct man files, you can use npm install npm -g to reinstall npm, or npm install $pkg -g to reinstall whatever package you had. (For example, if you already had blerg-llama-bl.1 in there, you might want to npm install -g blerg-llama to get man bl to work as intended.)
Sorry for the inconvenience. Hopefully this removes more pain in the long run than it has caused in the short term :)




https://github.com/npm/npm/issues/3653


above solution will delete all npm related files except:


 /usr/local/share/man/man7/semver.7

you should manually delete this and you will have no problem after that.

























































No comments:

Post a comment