Ask Your Question

fedora 28, npm - Error: Cannot find module 'semver'

asked 2018-05-16 19:09:57 -0600

varoon gravatar image
 [user@localhost ~]$ npm
    throw err;

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
[user@localhost ~]$ ^C

I am getting the above error when using the command npm to install a package. I tried reinstall nodejs using sudo dnf remove nodejs ans then sudo dnf install nodejs but I get this error during install

    Installed size: 38 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/2): npm-5.6.0- 205 kB/s | 4.3 MB     00:21    T(2/2): nodejs-8.11.0-1.fc28.x86 172 kB/s | 5.5 MB     00:32    
    Total                           299 kB/s | 9.8 MB     00:33     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                        1/1 
      Installing       : nodejs-1:8.11.0-1.fc28.x86_64          1/2 
      Installing       : npm-1:5.6.0-     2/2 
    Error unpacking rpm package npm-1:5.6.0-
    Error unpacking rpm package npm-1:5.6.0-
    error: unpacking of archive failed on file /usr/lib/node_modules/npm/node_modules/cacache: cpio: File from package already exists as a directory in system
  Running scriptlet: npm-1:5.6.0-     2/2 
error: npm-1:5.6.0- install failed
  Verifying        : nodejs-1:8.11.0-1.fc28.x86_64          1/2 
npm-1:5.6.0- was supposed to be installed but is not!
  Verifying        : npm-1:5.6.0-     2/2 

  nodejs.x86_64 1:8.11.0-1.fc28                                 

  npm.x86_64 1:5.6.0-                            

Error: Transaction failed
[user@localhost ~]$
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-25 14:30:57 -0600

varoon gravatar image

How I solved it-

sudo rm -rf /usr/lib/node_modules
sudo dnf remove nodejs
sudo dnf install nodejs

It appears they you can't install a newer version of npm other than the one provided with the fedora nodejs rpm. But that was mainly a side note as my problems seemed to have gone away when I removed the node_modules folder and then remove and reinstall nodejs.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-05-16 19:09:57 -0600

Seen: 1,074 times

Last updated: May 16 '18