I recently upgraded my system and I’m trying to compile a Firebase cloud functions project that used to work.
After running this:
firebase deploy --only functions
I get the following error:
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './commands/run-script.js'
npm ERR! Require stack:
npm ERR! - /snapshot/firepit/node_modules/npm/lib/npm.js
npm ERR! - /snapshot/firepit/node_modules/npm/lib/cli.js
npm ERR! - /snapshot/firepit/node_modules/npm/bin/npm-cli.js
npm ERR! 1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andrea/.npm/_logs/2023-09-22T14_40_37_566Z-debug-0.log
Error: functions predeploy error: Command terminated with non-zero exit code 1
The main issue seems to be this:
Cannot find module './commands/run-script.js'
This file is not part of my project and ChatGPT told me this:
./commands/run-script.js is not a file you should be concerned with creating or maintaining; it’s internal to the npm package. If a reference to this internal npm file is causing issues, it typically indicates a problem with the npm installation itself.
I’ve tried reinstalling npm but without luck.
Some extra details:
- my
package.json
file specifies node version 18 node -v
outputsv18.17.1
npm -v
outputs9.6.7
firebase --version
outputs12.5.4
Here’s a link to my error log:
https://gist.github.com/bizz84/38e969c705d06086403966833878a6a7
I can’t seem to figure this out. Any ideas?
2
Answers
As it turns out, the problem was that I had installed the firebase-tools with the auto-install script:
The fix was to remove them:
And then reinstall them with npm:
It appears the
firebase
cli is not using your expected node / npm installation. It reported node v16.16.0 and npm v8.19.4 in the log file.How did you install? Did you use
curl -sL firebase.tools | bash
? To make it easier to onboard user, I think the Firebase team is doing something unconventional here and download an entirely different node stack to run their tools…As a workaround, you may install it locally in your project. Something like this: