Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spine001 opened this issue Jan 25, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@spine001
Copy link

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

@yuchenshi
Copy link
Member

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.

@ervaibhavsinghal
Copy link

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'

@yuchenshi yuchenshi transferred this issue from firebase/firebase-tools Feb 7, 2022
@yuchenshi yuchenshi added the bug Something isn't working label Feb 7, 2022
@supercede
Copy link

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
Copy link

eryi commented Feb 21, 2022

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

@angwonson
Copy link

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

This solved it for me, thanks.

@Ockham-Byron
Copy link

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

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

@moertel
Copy link

moertel commented Apr 20, 2022

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.

@yuchenshi
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants