nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

install.sh fails

ychaouche opened this issue · comments

Operating system and version:

Linux Mint 17

nvm debug output:

No command 'nvm' found,

nvm ls output:

No command 'nvm' found,

How did you install nvm?

running install.sh

What steps did you perform?

download https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh
chmod +x
run

What happened?


$ ./install-nvm.sh                                                                                                                                                                                       
=> Downloading nvm from git to '/home/ychaouche/.nvm'                                                                                                                                                                                          
=> Cloning into '/home/ychaouche/.nvm'...                                                                                                                                                                                                      
remote: Enumerating objects: 356, done.
remote: Counting objects: 100% (356/356), done.
remote: Compressing objects: 100% (303/303), done.
remote: Total 356 (delta 39), reused 164 (delta 27), pack-reused 0
Receiving objects: 100% (356/356), 222.14 KiB | 0 bytes/s, done.
Resolving deltas: 100% (39/39), done.
Checking connectivity... done.
* (detached from FETCH_HEAD)
  master
=> Compressing and cleaning up git repository

=> Appending nvm source string to /home/ychaouche/.bashrc
=> Appending bash_completion source string to /home/ychaouche/.bashrc
ERROR: npm v9.2.0 is known not to run on Node.js v8.7.0. You'll need to upgrade
to a newer Node.js version in order to use this version of npm. This version of
npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You
can find the latest version at https://nodejs.org/.

ERROR:
/usr/local/lib/node_modules/npm/lib/utils/exit-handler.js:22
  const hasLoadedNpm = npm?.config.loaded
                           ^

SyntaxError: Unexpected token .
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:588:28)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:76:23)
=> Close and reopen your terminal to start using nvm or run the following to use it

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nv
$

What did you expect to happen?

I expected the script to install nvm

Is there anything in any of your profile files that modifies the PATH?

.bashrc

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

$ curl -I --compressed -v https://nodejs.org/dist/
* Hostname was NOT found in DNS cache
*   Trying 104.20.23.46...
* Connected to nodejs.org (104.20.23.46) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
*        subject: CN=*.nodejs.org
*        start date: 2022-01-11 00:00:00 GMT
*        expire date: 2023-02-11 23:59:59 GMT
*        subjectAltName: nodejs.org matched
*        issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*        SSL certificate verify ok.
> HEAD /dist/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: nodejs.org
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Thu, 15 Dec 2022 14:07:45 GMT
Date: Thu, 15 Dec 2022 14:07:45 GMT
< Content-Type: text/html
Content-Type: text/html
< Connection: keep-alive
Connection: keep-alive
< Last-Modified: Thu, 15 Dec 2022 13:05:04 GMT
Last-Modified: Thu, 15 Dec 2022 13:05:04 GMT
< Cache-Control: max-age=14400
Cache-Control: max-age=14400
< CF-Cache-Status: HIT
CF-Cache-Status: HIT
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
* Server cloudflare is not blacklisted
< Server: cloudflare
Server: cloudflare
< CF-RAY: 779fbf547bcfeedc-ATH
CF-RAY: 779fbf547bcfeedc-ATH
< Content-Encoding: gzip
Content-Encoding: gzip

<
* Connection #0 to host nodejs.org left intact
$

What shell are you running this in? It's only meant to be ran in bash, which is why the installation script pipes it to bash (downloading it first isn't any more secure; i'd suggest using the install command verbatim)

At any rate, the implication here is that you have a system node of v8.7.0 (which is very old) which is broken because you installed npm 9 on it (which doesn't support it). I'd suggest downgrading npm on it, or, uninstalling that node version completely.

Either way, the install script completed successfully - did you try the instructions at the end? Specifically, close and reopen your terminal.

FYI I just got this in a GitHub Codespace using the (now legacy):

"features": {
    "node": {
       "version": "12"

Per here I updated to ⬇️ and now it its working again

    "features": {
        "ghcr.io/devcontainers/features/node:1": {
            "version": "12"
        }
    },
    "postCreateCommand": ". ${NVM_DIR}/nvm.sh && nvm install 12",

Closing, since the OP's issue seems to not exist.

@davetapley that's interesting, but i'm not sure how that comment is relevant to this issue.

@ljharb sorry I should have been more specific, I got the same:

ERROR: npm XXX is known not to run on Node.js XXX. You'll need to upgrade

...


ERROR:
/usr/local/lib/node_modules/npm/lib/utils/exit-handler.js:22
  const hasLoadedNpm = npm?.config.loaded

and this is top hit on Google.

But yes to close

I’ve also got this error,
Any fix?

any updates for this issue ??