TypeError: Cannot read property 'uid' of undefined 오류

YU YU·2022년 7월 1일
0

AWS 배포시키기

목록 보기
8/11
Error: EACCES: permission denied, mkdir '/root/.pm2/logs'
    at Object.mkdirSync (fs.js:921:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:133:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
Error: EACCES: permission denied, mkdir '/root/.pm2/pids'
    at Object.mkdirSync (fs.js:921:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:141:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
Error: EACCES: permission denied, open '/root/.pm2/module_conf.json'
    at Object.openSync (fs.js:462:3)
    at Object.writeFileSync (fs.js:1384:35)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:149:10)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
Error: EACCES: permission denied, mkdir '/root/.pm2/modules'
    at Object.mkdirSync (fs.js:921:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:157:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)

                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

Error: EACCES: permission denied, open '/root/.pm2/module_conf.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
    at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:116:44)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
/usr/local/lib/node_modules/pm2/node_modules/@pm2/agent/src/InteractorClient.js:58
          if (stats.uid === 0) {
                    ^

TypeError: Cannot read property 'uid' of undefined
    at /usr/local/lib/node_modules/pm2/node_modules/@pm2/agent/src/InteractorClient.js:58:21
    at FSReqCallback.oncomplete (fs.js:168:21)

이 문제는 내가 AWS에

$ sudo apt-get install npm

으로 깔아서 버전이 12여서 생긴 문제이다.

다음과 같이 v14 버전으로 깔면 된다.

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
profile
코딩 재밌어요!

0개의 댓글