firebase CLI will not recognize current directory for 'firebase init'

▼魔方 西西 提交于 2019-12-22 00:29:48

问题


I am following a tutorial on Ionic Angular and it has come to the point where the instructor is having me publish my code to Firebase Hosting. First I used NPM to install the Firebase CLI. Then I was instructed to use the firebase init command. The issue is that the CLI doesn't seem to recognize the current directory that is selected in my terminal.

I run: cd /Users/MyUserName/myProjectsFolder/myProject/ Then I run firebase init and it displays:

You're about to initialize a Firebase project in this directory:

/Users/MyUserName

When I would expect it to read:

You're about to initialize a Firebase project in this directory:

/Users/MyUserName/myProjectsFolder/myProject

A little bit of googling found this page: https://firebase.google.com/docs/cli/

Which includes this passage:

To initialize a new project directory, change directories in the terminal to your desired project directory and run: firebase init

Based on this I would expect the steps I took to work.

I am confused. Has anyone ever run into this behavior? Can anyone think of a way to get the CLI to function as expected?

Thanks.


回答1:


  1. Got to folder:

    /Users/Username/

  2. Search for a file with name of firebase.json and Delete it.

  3. Reinstall firebase tool with this command (--unsafeper- to avoid permissions error messages & use sudo):

    $ sudo npm install --unsafeper- -g firebase-tools

  4. Then, go to your pubilc folder (you have to create one) which contains your HTML, JS, images and CSS files and use this command:

    $ sudo firebase init

    $ sudo firebase deploy

  5. The reset is easy and as mentioned in the firebase docs:

https://firebase.google.com/docs/hosting/quickstart




回答2:


I was also facing this problem and windows not able to recognize the firebase. I don't know the exact reason why it was behaving in such a manner but it solved the problem.

1) I installed the firebase-tools using a command on command prompt

npm install -g firebase-tools

and it didn't work. 2) I restarted the machine. 3) then again I executed the same command from step 1) npm install -g firebase-tools and it worked.



来源:https://stackoverflow.com/questions/48388247/firebase-cli-will-not-recognize-current-directory-for-firebase-init

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!