Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+13 votes

So I am currently trying to get cloud functions setup in our React project, but unfortunately, I am not having any success. I have installed Firebase CLI using npm install -g firebase-tools. I also have updated firebase-functions and firebase-admin to the latest version. After these things, one has to use the command in the terminal 'firebase login', but when I do this, this is what I get

$ firebase login

  throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\is-promise\index.js
require() of ES modules is not supported.
require() of C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\is-promise\index.js from C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\run-async\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\is-promise\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\is-promise\package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\CB\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14) {


I have tried what it has recommended other than the changing the requiring code to use import() because I do not know how to get that to work.

asked in CSC490_Spring2019 by (8 points)

1 Answer

+6 votes
Best answer

So a few things needed to be taken care of in order to fix this. First, I had to re-download Node.js to the newest version. Once that was done, I ran npm install -g firebase-tools again which added a few things. After that, I found out that in order to use firebase login in the terminal, you have to run firebase login --interactive

answered by (8 points)
selected by