George Ji
George Ji

Reputation: 11

Getting error: Cannot find module when trying to use yarn

I have installed yarn with npm install --global yarn, and when I run which yarn I get /Users/gerogeji/.nvm/versions/node/v18.19.1/bin/yarn.

However, when I try to run yarn --version (outside of any repository) I get the following error:

node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/Users/georgeji/.yarn/releases/yarn-1.19.0.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.19.1

The contents of my ~/.npmrc file is as follows:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

lastUpdateCheck 1741352724060
yarn-path "/Users/georgeji/.yarn/releases/yarn-1.19.0.cjs"

Would anyone know the fix for this/directions for further troubleshooting?

Upvotes: 0

Views: 33

Answers (0)

Related Questions