简体   繁体   中英

NVM - Updating NodeJS to the latest version - Ubuntu 18.04

I'm new to Node and trying to set up NodeJS on a local machine running Ubuntu 18 and Apache. I have NVM and NPM installed and NodeJS 8.10.0. I need at least 10.14.1 installed but when I run npm install nodejs-latest I get:

No such file or directory, open 'root/package.json'

And some warning messages.

If I run nvm install 10.21.0:

Downloading and installing node v10.21.0...
Downloading https://nodejs.org/dist/v10.21.0/node-v10.21.0-linux-x86.tar.xz...
##O=-#      #
curl: (22) The requested URL returned error: 404
Binary download from https://nodejs.org/dist/v10.21.0/node-v10.21.0-linux-x86.tar.xz failed, trying source.
grep: /home/matt6/.nvm/.cache/bin/node-v10.21.0-linux-x86/node-v10.21.0-linux-x86.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.

Along with that I get large variety of these:

g++ -o /home/matt6/.nvm/.cache/src/node-v10.21.0/files/out/Release/obj.host/v8_libbase/deps/v8/src/base/functional.o ../deps/v8/src/base/functional.cc '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=0' '-DOPENSSL_NO_PINSHARED' '-DV8_TARGET_ARCH_IA32' '-DV8_EMBEDDER_STRING="-node.56"'

If I run nvm list

-> iojs-v3.3.1

system

default -> iojs (-> iojs-v3.3.1)
iojs -> iojs-v3.3 (-> iojs-v3.3.1) (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.21.0 (-> N/A)
lts/erbium -> v12.18.2 (-> N/A)

Obviously I am not doing something right. Why can't I get another version of NodeJS installed?

Thanks!

nodejs-latest is not a means to install the latest version of NodeJS on your system. It's just a lib that helps you fetch metadata about the latest NodeJS version. Look it's source .

Now, about NVM. From the logs it's telling us that it's not finding the binaries at the https://nodejs.org/dist/v10.21.0/node-v10.21.0-linux-x86.tar.xz (indeed this URL gives a 404 page if you try to access from a browser).

What's the output of nvm --version on your system? My guess is that you're running an old version of NVM. Try updating NVM by running:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

And then try reinstalling NodeJS:

nvm install 10.21.0

Solution: Check it with nvm:

  1. List node.js installatios using nvm:

    nvm ls

  2. High chance the version you tried to install is also listed

  3. Select the version to use using nvm

    nvm use

wget http://curl.haxx.se/download/curl-7.49.0.tar.gz tar -xvf curl-7.49.0.tar.gz cd curl-7.49.0/./configure make sudo make install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM