Search code examples
javascriptnode.jsgatsbynpm-installubuntu-18.04

gatsby-cli installation is not recognising current Node version


I'm trying to install gatsby-cli in Ubuntu 18.04 using the command sudo npm install -g gatsby-cli.

My Node version is 16.14.2 and npm 8.5.0. But gatsby installation does not recognise these versions. It keeps saying that my current versions are Node 8.5.0 and npm 3.5.2, causing installation errors as you can see in the terminal output below.

What can I do to fix this?

WARN engine [email protected]: wanted: {"node":">=14.15.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:yurnalist → addNa 
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:yurnalist → addNa 
loadDep:yurnalist → resol 
WARN engine [email protected]: wanted: {"node":">=14.15.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=14.15.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
loadDep:is-wsl → 304
loadDep:wrap-ansi → resol 
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:typedarray-to-buf 
loadDep:strip-final-newli 
loadDep:mimic-fn → addNam 
loadDep:tmp → request     
npm ERR! Linux 4.15.0-176-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "gatsby-cli"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>
WARN engine [email protected]: wanted: {"node":">=8.17.0"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=12.2"} (current: {"node":"8.10.0","npm":"3.5.2"})
WARN engine [email protected]: wanted: {"node":">=10.19.0"} (current: {"node":"8.10.0","npm":"3.5.2"})

npm ERR! Please include the following file with any support request:
npm ERR!     /home/development/blog-gatsby/npm-debug.log

Solution

  • I managed to fix the error above. The problem was that, even using yarn or npm without sudo, the installation process happened with the Node version installed for the root user, which was 8.10.0.

    To fix that, I logged as a root user and did:

    curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    sudo apt-get install -y nodejs
    

    After that, the command gatsby was installed with no issues with the command sudo npm install -g gatsby-cli.

    Hope this could be helpful for someone.