firebase/quickstart-testing

Shell Cloud for testing Firebase Security Rules Instructions lead to: Error: Cannot find module 'firebase/compat/database'

spine001 opened this issue ยท 8 comments

I started by having problems with my firebase security rules, I tested them in the security rules playground, but since my rules depend on the resource.data.userId, they failed with a null when I tried to test the update instruction. I couldn't find any way to set a resource baseline in the playground. So I decided to give a try a second time to the: https://ssh.cloud.google.com/cloudshell/editor?environment_deployment=firebase&walkthrough_id=firebase_emulator_rules_quickstart
I followed the instructions to the detail, three times, first a few months ago and gave up due to the time is was taking to try to figure this out. Today, I tried again two times, the last time after rebaselining my ssh.cloud.google shell.
It starts with some warnings about requiring node 10 but loading node 12. I am not choosing node version but executing their scripts on the instructions.
The details of what it is showing me is in the attached log files.

Please help!

firebase-debug.log
firestore-debug.log
ui-debug.log

Would you mind describing the steps you took before you see the 'firebase/compat/database' error? And where does that error appear? e.g. In Emulator UI? In your app? etc.

I've faced the same issue; when I've tried Cloud Shell on step 4.5 and tried to execute the command:

npm --prefix=functions test

then I've got the error is:

/home/dir-name/rules-tutorial/quickstart-testing/cs-walkthrough/functions/node_modules/mocha/node_modules/yargs/yargs.js:1163
      else throw err
           ^

Error: Cannot find module 'firebase/compat/database'

I've faced the same issue; when I've tried Cloud Shell on step 4.5 and tried to execute the command:

npm --prefix=functions test

then I've got the error is:

/home/dir-name/rules-tutorial/quickstart-testing/cs-walkthrough/functions/node_modules/mocha/node_modules/yargs/yargs.js:1163
      else throw err
           ^

Error: Cannot find module 'firebase/compat/database'

I have this issue too when I run npm --prefix=functions test

eryi commented

I randomly reverted to to commit d46034231738952e3befd7abc0e9a4d041eab591 and do not face this issue.

I randomly reverted to to commit d46034231738952e3befd7abc0e9a4d041eab591 and do not face this issue.

This solved it for me, thanks.

I randomly reverted to to commit d46034231738952e3befd7abc0e9a4d041eab591 and do not face this issue.

Thanks for your answer ! How do you do that ? Thanks

Reverting to d46034231738952e3befd7abc0e9a4d041eab591 solved it for me too.

@Ockham-Byron, if you've followed all steps of the tutorial, you'd need to run these commands:

cd ~/rules-tutorial/quickstart-testing/cs-walkthrough/
git stash   # optional, takes any local changes you might have and puts them aside
git checkout d46034231738952e3befd7abc0e9a4d041eab591   # pin the code to this particular commit
git stash pop   # optional, brings back your local changes
npm --prefix=functions install

Afterwards the npm --prefix=functions test command will succeed.

If you later want to undo it, you'd need to run those steps again but with master instead of the commit ID.

Hi all, I've made a release branch for the last known working version. So you can just git clone https://github.com/firebase/quickstart-testing -b release (e.g. in tutorial Step 3). Instruction updates coming soon.