npm error invalid semver

10,528

Solution 1

You have an older version of normalize-package-data (the current version depends on semver version 2: https://github.com/meryn/normalize-package-data/blob/master/package.json#L15 )

To forcefully reinstall npm without using npm, try using the shell script

curl https://npmjs.org/install.sh | sh

Solution 2

Try un/reinstalling it if you are sure you aren't using it. That should get rid of the error message.

npm un semver -g and then npm install semver -g

Edit: it seems that one of your modules needs [email protected] so try sudo npm install [email protected] -g

Solution 3

Note the URL has moved to: https://www.npmjs.com/install.sh (as of Apr 2015)

This should work:

curl https://npmjs.com/install.sh | sh
Share:
10,528

Related videos on Youtube

Esa
Author by

Esa

Updated on June 08, 2022

Comments

  • Esa
    Esa 7 months

    Just installed Node.js v.0.10.20 from source. Target box Ubuntu 12.04.3 LTS. Node is installing ok without errors. After all it seems :

    node -v
    v0.10.20
    npm -v
    1.3.11
    

    But just listing my -g modules, I get some odd messages I can't figure out :

    [email protected]:~$ npm list -g
    npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/normalize-package-data requires [email protected]'1.x' but will load
    npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/semver,
    npm WARN unmet dependency which is version 2.1.0
    

    and at a bottom of -g listing, I see more messages :

    npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/semver
    npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/normalize-package-data
    npm ERR! not ok code 0
    

    Also I can see under [email protected] -module the row:

    │ ├── [email protected] invalid
    

    This same happens in previous node version (0.10.18) if I remember that right.

    Annoying message that I can't solve. I'm sure I haven't installed semver-module manually and quite sure that none of my installed node-modules is using semver.


    Edit: thanks to Nirk, re-installing npm will solve this. To be sure, I gave sudo su - and re-installed as root. Maybe just sudo:ing works as well.

    Here is what I did :

    sudo su -
    [email protected]:~# curl https://npmjs.org/install.sh | sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7882  100  7882    0     0  13118      0 --:--:-- --:--:-- --:--:-- 23669
    tar=/bin/tar
    version:
    tar (GNU tar) 1.26
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Written by John Gilmore and Jay Fenlason.
    install [email protected]
    fetching: http://registry.npmjs.org/npm/-/npm-1.3.11.tgz
    0.10.20
    1.3.11
    cleanup prefix=/usr/local
    All clean!
    unbuild [email protected]
    /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
    [email protected] /usr/local/lib/node_modules/npm
    It worked
    [email protected]:~#
    

    Note that URL has moved to https://npmjs.org/install.sh

  • Esa
    Esa about 9 years
    Yes, it works! No `npm list -g´is clean. Maybe this is not causing any harm anyway, but better be sure. Thanks. I will edit my original question with verbose solution, if someone else needs it.

Related