0

I'm trying to use PM2 or Forever on a Raspberry Pi 3B, but when I try running the command pm2, I get this error:

Error: Cannot find module 'read'
Require stack:
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/node_modules/promptly/index.js
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/lib/API/pm2-plus/PM2IO.js
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/bin/pm2
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/node_modules/promptly/index.js:3:12)
    at Module._compile (/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/node_modules/promptly/index.js',
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/lib/API/pm2-plus/PM2IO.js',
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/pm2/bin/pm2'
  ]
}

When I run Forever, I get a similar error:

Error: Cannot find module 'pkginfo'
Require stack:
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/node_modules/winston/lib/winston.js
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/node_modules/cliff/lib/cliff.js
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/lib/forever.js
- /home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/bin/forever
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/node_modules/winston/lib/winston.js:14:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/node_modules/winston/lib/winston.js',
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/node_modules/cliff/lib/cliff.js',
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/lib/forever.js',
    '/home/pi/.nvm/versions/node/v12.10.0/lib/node_modules/forever/bin/forever'
  ]
}

My node version is v12.10.0 and npm is 6.10.3. Both were installed using nvm. I've also tried installing pm2 locally and running it with ./node_modules/.bin/pm2, but I get the same error. I've installed these packages following the same steps on my Macbook, Ubuntu desktop, and several AWS EC2 instances running Ubuntu without seeing these issues, so I'm guessing it's related to the PI or Raspbian.

Why am I missing these dependencies?

Note: I also posted this question on stack overflow, but this seems to be a more appropriate place to ask.

  • Stack overflow is a better spot. This site is for software/hardware specific to the Pi, and this looks like a more general node issue of some soft. – Fred Sep 24 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.