MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    NPM install is giving Error.

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    18 Posts 11 Posters 28.3k Views 11 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Alex_
      last edited by

      @postremalone said in NPM install is giving Error.:

      NPM install is giving error.

      alt text

      Help please.

      I meet the same issue than you and I solved it by uninstalling nodejs

      sudo apt-get remove nodejs
      

      and reinstall nodejs by using the MagicMirror install script

      bash -c "$(curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh)"
      

      During the installation, npm install -g npm@latest give me this error

      npm ERR! path /usr/lib/node_modules/npm/node_modules/ansi-regex
      npm ERR! code EACCES
      npm ERR! errno -13
      npm ERR! syscall access
      npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm/node_modules/ansi-regex'
      npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules/npm/node_modules/ansi-regex'
      npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules/npm/node_modules/ansi-regex\'',
      npm ERR!   errno: -13,
      npm ERR!   code: 'EACCES',
      npm ERR!   syscall: 'access',
      npm ERR!   path: '/usr/lib/node_modules/npm/node_modules/ansi-regex' }
      npm ERR!
      npm ERR! Please try running this command again as root/Administrator.
      
      

      and I run same command as root to solved this

      sudo npm install -g npm@latest
      

      Here is version of nodejs install by MagicMirror script :

      Installed Node version: v9.11.2
      
      1 Reply Last reply Reply Quote 0
      • E Offline
        epi
        last edited by

        pi@raspberrypi:~/MagicMirror $ npm start
        
        > magicmirror@2.4.1 start /home/pi/MagicMirror
        > sh run-start.sh
        
        /home/pi/MagicMirror/node_modules/electron/index.js:1
        (function (exports, require, module, __filename, __dirname) {
        
        
        SyntaxError: Invalid or unexpected token
            at new Script (vm.js:51:7)
            at createScript (vm.js:136:10)
            at Object.runInThisContext (vm.js:197:10)
            at Module._compile (internal/modules/cjs/loader.js:618:28)
            at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
            at Module.load (internal/modules/cjs/loader.js:566:32)
            at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
            at Function.Module._load (internal/modules/cjs/loader.js:498:3)
            at Module.require (internal/modules/cjs/loader.js:598:17)
            at require (internal/modules/cjs/helpers.js:11:18)
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! magicmirror@2.4.1 start: `sh run-start.sh`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the magicmirror@2.4.1 start script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        
        npm ERR! A complete log of this run can be found in:
        npm ERR!     /home/pi/.npm/_logs/2018-09-13T10_40_56_673Z-debug.log
        
        1 Reply Last reply Reply Quote 0
        • D Offline
          devinhedge @NoNameRo
          last edited by

          @nonamero I’ve brought this up on another thread, but I’ll mention here so that it is captured in context: for the last couple months Node.js and npm are currently BROKEN on RaspberryPi.

          I just tried a test this morning using the started Electron app at https://electronjs.org/docs/tutorial/first-app

          Running the automated install is a Red Herring. It is inappropriate to suggest it.

          We have to figure out how to fix the bugs in the Node.js installation for Raspberry Pi before anything else. I’m wondering if installing an older version of Node.js is the solution. If so, then what version would we start with?

          1 Reply Last reply Reply Quote 0
          • P Offline
            paddyhughes @postremalone
            last edited by

            @postremalone

            I just installed a module and it asked me to update NPM think i did it in the root directory not MagicMirror one can be sure.

            This is what worked for me
            sudo npm i -g npm

            1 Reply Last reply Reply Quote 0
            • R Offline
              rmeskill
              last edited by

              Aha-got it!

              sudo rm -rf ~/.nvm
              sudo rm /usr/local/bin/node
              sudo rm /usr/local/bin/nvm
              pm2 stop mm (not sure if I missed this earlier)
              bash -c "$(curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh)"
              

              This installed fine, but gave me an error of an out-of-date npm version, so I ran:

              sudo npm i -g npm
              

              Then moved all my old modules and config file over to the new install and checked my node/npm versions:

              pi@raspberrypi:~/MagicMirrorBackup/modules $ node -v
              v9.11.2
              pi@raspberrypi:~/MagicMirrorBackup/modules $ npm -v
              6.5.0
              

              So they’re not as up-to-date as my previous ones, but MagicMirror is working fine!

              Thanks everyone for the input, turns out just a bit of manual removal and persistence sorted me out!

              1 Reply Last reply Reply Quote 1
              • 1
              • 2
              • 2 / 2
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy