I installed firebase-tools with
npm install -g firebase-tools
However when I do firebase init or other cli commands I get an error.
firebase
node:internal/modules/cjs/loader:444
throw err;
^
Error: Cannot find module 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\socks-proxy-agent\dist\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:436:19)
at Module._findPath (node:internal/modules/cjs/loader:678:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\pac-proxy-agent\dist\index.js:39:29)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\12155\\AppData\\Roaming\\npm\\node_modules\\firebase-tools\\node_modules\\socks-proxy-agent\\package.json',
requestPath: 'socks-proxy-agent'
}
Node.js v18.16.0
Issue started when I ran npm install -g firebase-tools when I already had it installed, prior to that firebase cli was working. However uninstalling and reinstalling didn't work. Even tried deleting the firebase cli folder, but nothing works. Also I saw some other posts online about deleting the node modules folder, but I am just trying to use the firebase cli there is no node modules folder to delete.
I encountered this issue before and fixed it, but I am not sure how it was resolved as it was too long ago. I am on a windows computer.
Edit: Warnings that I got when I installed firebase tools
>npm install -g firebase-tools
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\socks-proxy-agent\dist\index.js.DELETE.12e9f100a7307238826cd2a1e93e2ca4'
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\socks-proxy-agent\node_modules\agent-base\dist\index.js'
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\proxy-agent\node_modules\agent-base\dist\index.js'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\pac-resolver\dist\index.js.DELETE.ceb31c0dc58c707624f6211476b72eb4'
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'C:\Users\12155\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\get-uri\dist\index.js.DELETE.006f3dd7d637272339a132b0d45dcb9d'
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
reinstalling node somehow fixed the issue. Neeeded to reinstall a few times.