I have a blog app where I want to connect the frontend with firebase real time database. So I installed firebase using
npm install firebase --save as mentioned in the firebase docs. But am not able to import firebase using
import firebase from 'firebase/app'. It says the module firebase is unknown. I even tried without ‘/app’ but still not working?
Can someone help me solve this issue?
I tried the other approaches like emberfire and ember-firebase-service. But still not working. Although the error is not the same as the above.
Would be helpful if someone can mention why I am not able to import firebase in the import statement?
In Ember you can’t yet just use a 3rd party module without ingesting it into the build somehow. There are several ways to do this. Most likely what you want is to use ember-auto-import if you aren’t already. You could also import firebase using your ember-cli-build. If you look at the current emberfire code it appears they are using ember-auto-import. Do you have ember-auto-import installed already?
I installed ember-auto-import and now its working fine. Thank you @dknutsen. Is that the reason why we have to ember install packages instead of yarn/npm install?
That’s actually a separate thing. I’ll try to give a high level of both.
RE: ember install, we encourage
ember install instead of
yarn/npm install because ember addons have these extra bits called blueprints which can do special stuff when installing e.g. add a new file to your project or run some other node code to configure the new addon. There’s nothing stopping you from using yarn or npm install commands, but sometimes you’ll then need to manually run the addon blueprint.