Npm ERR! code EACCES when running npm install -g ghost-cli@latest

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

  • What’s your URL? This is the easiest way for others to help you
    bowiesensei.com

  • What version of Ghost are you using? If it’s not the latest, please update Ghost first before opening your topic
    Ghost version: 5.53.1
    And

  • How was Ghost installed and configured?
    DigitalOcean 1 click and configuration myself.

  • What Node version, database, OS & browser are you using?
    Node v16.20.1
    MacOS Monteray
    Chrome

  • What errors or information do you see in the console?
    N/A

  • What steps could someone else take to reproduce the issue you’re having?

I’m getting a message You are running an outdated version of Ghost-CLI. It is recommended that you upgrade before continuing. Run npm install -g ghost-cli@latest to upgrade.

However, when I run npm install -g ghost-cli@latestas the ghost-mgr user I get the following.

npm ERR! code EACCES

npm ERR! syscall rename

npm ERR! path /usr/lib/node_modules/ghost-cli

npm ERR! dest /usr/lib/node_modules/.ghost-cli-no3HtXlj

npm ERR! errno -13

npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/ghost-cli' -> '/usr/lib/node_modules/.ghost-cli-no3HtXlj'

npm ERR! [Error: EACCES: permission denied, rename '/usr/lib/node_modules/ghost-cli' -> '/usr/lib/node_modules/.ghost-cli-no3HtXlj'] {

npm ERR! errno: -13,

npm ERR! code: 'EACCES',

npm ERR! syscall: 'rename',

npm ERR! path: '/usr/lib/node_modules/ghost-cli',

npm ERR! dest: '/usr/lib/node_modules/.ghost-cli-no3HtXlj'

npm ERR! }

npm ERR!

npm ERR! The operation was rejected by your operating system.

npm ERR! It is likely you do not have the permissions to access this file as the current user

npm ERR!

npm ERR! If you believe this might be a permissions issue, please double-check the

npm ERR! permissions of the file and its containing directories, or try running

npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:

npm ERR! /home/ghost-mgr/.npm/_logs/2023-07-05T17_23_30_492Z-debug-0.log

After reading the output it mentioned a log file.

npm ERR! /home/ghost-mgr/.npm/_logs/2023-07-05T17_23_30_492Z-debug-0.log

I cd to the log destination, opened that in nano editor and towards the bottom I found this

1818 error code EACCES

1819 error syscall rename

1820 error path /usr/lib/node_modules/ghost-cli

1821 error dest /usr/lib/node_modules/.ghost-cli-no3HtXlj

1822 error errno -13

1823 error [Error: EACCES: permission denied, rename '/usr/lib/node_modules/ghost-cli' -> '/usr/lib/node_modules/.ghost-cli-no3HtXlj'] {

1823 error errno: -13,

1823 error code: 'EACCES',

1823 error syscall: 'rename',

1823 error path: '/usr/lib/node_modules/ghost-cli',

1823 error dest: '/usr/lib/node_modules/.ghost-cli-no3HtXlj'

1823 error }

1824 error

1824 error The operation was rejected by your operating system.

1824 error It is likely you do not have the permissions to access this file as the current user

1824 error

1824 error If you believe this might be a permissions issue, please double-check the

1824 error permissions of the file and its containing directories, or try running

1824 error the command again as root/Administrator.

1825 verbose exit -13

1826 timing npm Completed in 16481ms

1827 verbose unfinished npm timer reify 1688577810654

1828 verbose unfinished npm timer reify:retireShallow 1688577826946

1829 verbose code -13

1830 error A complete log of this run can be found in:

1830 error /home/ghost-mgr/.npm/_logs/2023-07-05T17_23_30_492Z-debug-0.log

I exited ghost-mgr user and running the same command as root it worked.