Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'npmlog' - zsh #2441

Open
AaronMcCloskey opened this issue Feb 17, 2021 · 5 comments
Open

Error: Cannot find module 'npmlog' - zsh #2441

AaronMcCloskey opened this issue Feb 17, 2021 · 5 comments

Comments

@AaronMcCloskey
Copy link

Operating system and version:

nvm debug output:

nvm --version: v0.35.3
$TERM_PROGRAM: vscode
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/aaron
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v10.16.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:./node_modules/.bin:${HOME}/.npm/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.rvm/bin::/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.rvm/bin::/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.rvm/bin::/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.rvm/bin::/Applications/Visual Studio Code.app/Contents/Resources/app/bin:${HOME}/Library/Android/sdk/emulator:${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/tools/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.rvm/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'
uname -a: 'Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.6 19G2021
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: not found
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.14.1
ls: grep:: No such file or directory
grep: grep: aliased to grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: v10.16.2
which node: ${NVM_DIR}/versions/node/v10.16.2/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v10.16.2/bin/npm
npm config get prefix: internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at ${NVM_DIR}/versions/node/v10.16.2/lib/node_modules/npm/bin/npm-cli.js:22:13
    at Object.<anonymous> (${NVM_DIR}/versions/node/v10.16.2/lib/node_modules/npm/bin/npm-cli.js:152:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
npm root -g: internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at ${NVM_DIR}/versions/node/v10.16.2/lib/node_modules/npm/bin/npm-cli.js:22:13
    at Object.<anonymous> (${NVM_DIR}/versions/node/v10.16.2/lib/node_modules/npm/bin/npm-cli.js:152:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

nvm ls output:

->     v10.16.2
       v10.16.3
       v14.15.5
default -> 10.16.2 (-> v10.16.2)
node -> stable (-> v14.15.5) (default)
stable -> 14.15 (-> v14.15.5) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/fermium (-> v14.15.5)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.3 (-> N/A)
lts/erbium -> v12.20.2 (-> N/A)
lts/fermium -> v14.15.5

How did you install nvm?

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

What steps did you perform?

Running

npm config delete prefix

returns

env: node: No such file or directory

Running

nvm use --delete-prefix v10.16.2 --silent

returns the Cannot find module 'npmlog' error

nvm current

v10.16.2

When I run

echo $PATH

I no longer see the nvm path to npm?

I used to see

/Users/{user}/.nvm/versions/node/v10.16.2/bin:

If I install a new version of node, it works, but when I close my terminal and reopen, I'm back to square one.

which node

returns

node not found

and

which npm

seems to not be targeting nvm

/Users/{user}/.npm/bin/npm

What happened?

Still getting the same error attempting to find npmlog module

What did you expect to happen?

No error message on all node/npm related commands

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

.zshrc

PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
export VS_CODE_DEV_MODE=true
export PATH="$PATH:$HOME/.rvm/bin"

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

*   Trying 2606:4700:10::6814:172e...
* TCP_NODELAY set
* Connected to nodejs.org (2606:4700:10::6814:172e) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.nodejs.org
*  start date: Oct 21 00:00:00 2019 GMT
*  expire date: Jan 18 23:59:59 2022 GMT
*  subjectAltName: host "nodejs.org" matched cert's "nodejs.org"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fd7f9809600)
> HEAD /dist/ HTTP/2
> Host: nodejs.org
> User-Agent: curl/7.64.1
> Accept: */*
> Accept-Encoding: deflate, gzip
> 
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200 
HTTP/2 200 
< date: Wed, 17 Feb 2021 12:26:47 GMT
date: Wed, 17 Feb 2021 12:26:47 GMT
< content-type: text/html
content-type: text/html
< set-cookie: __cfduid=d75fc5c9edf777e37cb7e3217ddab85111613564807; expires=Fri, 19-Mar-21 12:26:47 GMT; path=/; domain=.nodejs.org; HttpOnly; SameSite=Lax
set-cookie: __cfduid=d75fc5c9edf777e37cb7e3217ddab85111613564807; expires=Fri, 19-Mar-21 12:26:47 GMT; path=/; domain=.nodejs.org; HttpOnly; SameSite=Lax
< cache-control: max-age=14400
cache-control: max-age=14400
< cf-cache-status: HIT
cf-cache-status: HIT
< age: 7359
age: 7359
< cf-request-id: 08518e1f7300002d2816a79000000001
cf-request-id: 08518e1f7300002d2816a79000000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< vary: Accept-Encoding
vary: Accept-Encoding
< server: cloudflare
server: cloudflare
< cf-ray: 622f7fabedf52d28-LHR
cf-ray: 622f7fabedf52d28-LHR
< content-encoding: gzip
content-encoding: gzip

< 
* Connection #0 to host nodejs.org left intact
* Closing connection 0
@Trott
Copy link

Trott commented Feb 17, 2021

What happens if you install the latest version?

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

@ljharb
Copy link
Member

ljharb commented Feb 17, 2021

The issue is that you have $HOME/.npm in your PATH. That directory is npm’s cache directory and should never be directly used by users.

@AaronMcCloskey
Copy link
Author

The issue is that you have $HOME/.npm in your PATH. That directory is npm’s cache directory and should never be directly used by users.

I had removed that and ran

source ~/.zshrc

still had the same issues.

@AaronMcCloskey
Copy link
Author

What happens if you install the latest version?

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

This seems to have worked for now.

However, I did also do the following #298 (comment)

@ljharb
Copy link
Member

ljharb commented Feb 17, 2021

You shouldn't need --delete-prefix either - does it work without that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants