I attempted to update npm via different means (console and npm-windows-upgrade), ended up with multiple installations and decided to uninstall everything, clear the path and start over again.
After installing the newest lts version via the installer from https://nodejs.org/en/ npm and node versions are displayed correctly
node -v
v16.14.2
npm -v
8.5.0
Now running npm install
results in the error
Error: Cannot find module 'are-we-there-yet'
Require stack:
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\npmlog\log.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\lib\node-pre-gyp.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\lib\main.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
...
code: 'MODULE_NOT_FOUND',
NodeJs installation directory:
C:\Program Files\nodejs
Are-we-there-yet is present in the node_folder
C:\Program Files\nodejs\node_modules\npm\node_modules\are-we-there-yet
npm prefix -g
resolves to C:\Users\Kilian\AppData\Roaming\npmC:\Program Files\nodejs\
is in the PATH and nothing other nodejs or npm related
PS C:\Users\Kilian\git\FooBar> npm config ls -l
; "default" config from default values
_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\Kilian\\AppData\\Local\\npm-cache"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
ci-name = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\Kilian\\AppData\\Roaming\\npm\\etc\\npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\Kilian\\.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "C:\\Users\\Kilian\\.npm-init.js"
init.version = "1.0.0"
json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
node-version = "v16.14.2"
noproxy = [""]
npm-version = "8.5.0"
offline = false
omit = []
only = null
optional = null
otp = null
pack-destination = "."
package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" ; overridden by builtin
preid = ""
production = null
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "C:\\Users\\Kilian\\AppData\\Local\\Temp"
umask = 0
unicode = true
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "C:\\Users\\Kilian\\.npmrc"
version = false
versions = false
viewer = "browser"
which = null
workspace = []
workspaces = null
yes = null
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\Kilian\\AppData\\Roaming\\npm"
; "user" config from C:\Users\Kilian\.npmrc
python = "C:\\Users\\Kilian\\.windows-build-tools\\python27\\python.exe"
; "cli" config from command line options
long = true
I am a bit of a loss on why npm does not find the correct module. Do I have to explicitly set a path to the nodejs directory are there config file conflicts left over from the previous install?
I would like to understand the culprit so it can be properly fixed and not cause issues with global installation of packages down the line.
Npm run in the console is actually the one installed with nodejs:
PS C:\Users\Kilian\git\FooBar> gcm npm
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
CodePudding user response:
In my case the issue resolved itself after doing a simple npm install
on a fresh initialized repo. I can not tell if this finally solved the issue or if it was something else but now it is working again.
CodePudding user response:
That's good you managed to resolve it!
It could be possibly related to some cache issues or package-lock.json content, next time it happens you could try removing the lock file and/or cleaning npm cache.