简体   繁体   中英

How to change Firebase project directory

I have installed Firebase hosting project into my machine by referring following docs:

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

Now, I want to change the location of my project directory. Wha should I do for this?

Till now I have tried by relogin and re-initialize the project but it does not give option to specify directory again.

Go to the file called firebase.json located in the root of the project and change the field called public in hosting to the directory you want.

{ 
"database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public", <------ This points to directory
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Try these steps

1- create a new directory/folder somewhere on your computer 2- open your command line terminal eg git/cmd from the created directory by doing the following a) for git: right click on directory and choose git b) for windows cmd: shift + right on created directory and choose cmd 3- type the command firebase init

在你的npm命令中,转到该文件夹​​所在的目录并键入firebase init最简单的方法是打开Node.js并键入cd“your_directory”而不输入q

Not sure if this is the best way, but none of the other solutions worked for me. I ended up copying the firebase.json file to the new folder I created. I opened the file and updated the public setting to the correct public folder (might be the same, but if you have a React app, you'll want "build" folder).

Then I did firebase init in the new folder through the CLI. This set the correct project folder.

For the Firebase CLI use:

cd.. - Go back to previous directory

cd <dir_name> - To move to <dir_name> folder in current directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM