installing and setting up firebase cli on ubuntu 16.04 - firebase

with node and npm installed, I commenced by running
sudo npm install -g firebase-tools
on my terminal. On trying out
firebase login
firebase: command not found
thats the response I get. I tried
alias firebase="`npm config get prefix`/bin/firebase"
which only works for a single response only. I can't initialize firebase nor serve on the machine.
Its using ubuntu 16.04

try running sudo firebase login from what i understand is that if you install at admin level it can only be accessed at admin level too...

Related

Something went wrong installing JavaScript dependencies, check your npm logfile or run npm install again manually [duplicate]

I am using react native and Expo. I am unable to build new app because after I use expo init appName it shows the following error.
Heres the full message:
📦 Using npm to install packages. You can pass --yarn to use Yarn instead.
√ Downloaded and extracted project files.
× Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd Scanner
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
I tried multiple times to create a blank project, also tried npm install to install failed/not downloaded libraries and continue after failure but it showed another error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
also tried npm cache verify that showed cache is ok Content verified: 3562 (252580364 bytes).
So, How can I solve this issue?
Problems related to npm installation are very common If you do any mistake in early installation, but is avoided. Learn more about npm tree.
Steps worked for me are :
npm cache clean --force
npm cache verify
npm -g uninstall expo-cli --save
npm install expo-cli --global
expo init app-name
cd app-name
npm start
Always run as administrator if working on Windows and in root directory.
The solutions above didn't work for me but if you use 'npm install' in the directory of the app you get a clue that you shuold try 'npm install --force'
err message
You should have all these files folders and files at the start of the project otherwise not all the dependencies have been installed which is why we were getting the problem.folder structure
After you have added --force to npm install you have all the dependencies installed. Now you can run the app with npm start.
Unfortunately, all the solutions described above didn't work on my machine...
Here is my latest solution for this problem...
This worked 100% on my machine...
Use npm i -g expo-cli
This will automatically add the required packages and also remove the unnecessary ones.
Yes, surely, you don't need to uninstall and re-install it again.
Just follow my steps.
And, you can create your expo project using expo init.
I hope my solution will help you out from this annoying problem....
I just did npm install and it worked for me, but I had do that every time I create a new expo project.
I also encountered this problem, and finally found that it was the problem of react native cli,I installed the latest version of react native cli,Expo is back to normal
This Error is regarding to the git account. expos need a git account to setup react native project
If you are using windows you need to install git in your local PC
after that open your Terminal and type this command
git config --global user.name "your_username"
git config --global user.email "your_email_address#example.com"
after that clone any github project to your local computer. it will ask to login to Github
after all these steps try expo init <projectname>
The simple way to settle that error is by using "expo-cli init app-name" instead of "expo init app-name".
I tried and worked perfectly for me. Hope it will help you guys.
i have faced a similar problem and running yarn set version 1.22.1 fix it
Run the Command Prompt as an administrator. And run the following command:
npx create-expo-app AwesomeProject

I cannot run firebase commands in my terminal

I installed firebase using sudo npm install -g firebase-tools command on my Mac. Then I try to run firebase -v, it gives the below error.
Error: EACCES: permission denied, open '/Users/randiltennakoon/.config/configstore/firebase-tools.json'
You don't have access to this file.
While I was searching regarding this issue, I found this webpage.
So, according to that, I ran sudo chown -R $USER ~/.config/configstore on my terminal & it fixed my issue. Now I can see the firebase version using the firebase -V command.

Codeship + Firebase functions:config:set = 404 method not found

Hi wonderful people of stackoverflow!
Background
I have an Angular 9 application and CI set up with Codeship. This has been running fine until about two weeks ago when suddenly it stopped working after I upgraded from Angular 7.
Set up commands:
nvm ls
nvm install v10.15.1
nvm use v10.15.1
gem install rb-inotify -v 0.9.10
gem install sass
npm install -g firebase-tools#6.12.0
npm i firebase-functions#3.3.0
yes | npm install -g #angular/cli#9.1.12
npm i
cd functions
nvm use v10.15.1
npm i
cd ..
Which runs as expected. I have checked the versions in the CI environment with npm outdated, which show me that the correct versions are being installed the same as local:
Deploy script:
firebase use default
firebase functions:config:set test="test" --token "$FIREBASE_TOKEN"
firebase deploy --token "$FIREBASE_TOKEN"
Error:
firebase use default is successful, but firebase functions:config:set test="test" --token "$FIREBASE_TOKEN" now returns:
Error: HTTP Error: 404, Method not found.
Notes:
I've reset up the $FIREBASE_TOKEN with the new cli and can confirm that this probably isn't the issue, because when the token is incorrect (I removed the last character from the TOKEN), it throws a different error stating this.
I can also confirm that the same script run locally works and deploys just fine - so while I can get around the problem this way, it isn't an ideal or long term solution.
Any ideas or help would be genuinely appreciated as I'm somewhat lost as to what to do next?
This seems to be related with firebase-tools version. When I installed the same version as you have (6.12.0) I got the same error.
I have tried on new version (I have 8.7.0) and it is working fine with one more remark. When I tried exactly the same command as you have error:
Error: Invalid argument, each config value must have a 2-part key (e.g. foo.bar).
So working command will be like this:
firebase functions:config:set test.test="test"
If you need old version of firebase-tools I tested few other versions and it seems that this is working since version 7.1.0.
For anyone else having this issue - I never managed to solved this sorry. However I migrated my CI over to use GitHub Actions easily and it all works without any issue.

after I `npm install -g` something, I cannot use the CLI commands from the installed package

my npm install -g is not working as intended. It installs the package I need, however the CLI commands which comes from the package is always absent.
One example is, I was following the quick start on TypeORM.
It says
First, install TypeORM globally:
npm install typeorm -g
Then go to the directory where you want to create a new project and run the command:
typeorm init --name MyProject --database mysql
but when I tried typeorm init --name MyProject --database mysql. I got the error -bash: typeorm: command not found I think it has something to do with my environment path setting.
This is the output from my echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/aria2/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Postgres.app/Contents/Versions/latest/bin
Can someone help me with this?
OK I figured this out myself. Solution is here : https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
In Linux/Unix, if you are a normal user, i.e. not root, you cannot install global packages, as these packages are written to system folders. In your case, -g is doing nothing as it cannot access system folders, so it is installed locally as any other regular package. in order to fix your problem, you have to gain more privileges. To do so, you can run the command at the root level i.e:
sudo npm install typeorm -g
and then you can access it from anywhere as -g is intended to put it as global; no need to play with environment path settings as -g also take care of doing so.
if you need a bash session as full root (a root terminal, or in windows terms a cmd/powershell running as administrator) without really signing in to root account for security purpose, use:
sudo -i
and then do whatever you want as root without writing sudo everytime :D; as i said, this command opens the current terminal session as root, so you have to write it in each new opened terminal.
Hope it helps :D (It wiill actually ;))
To install package binary globally, npm needs to create links to /usr/local/bin, which may not happen if you don't give it permission. Try running with sudo.
$ sudo npm install typeorm -g
You can run
$ which typeorm
To check if it's installed properly.
You can use node version manager (nvm). But first uninstall your node.js.
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Then
command -v nvm
Then exit and open your terminal.
Then you can install any version of node.js.
For install the latest version type:
nvm install node
When the installation is complete install your package:
npm install typeorm -g
Then it should work correctly.
I think im a bit late but it might help someone :D
sudo npm install typeorm -g --unsafe-perm

firebase-tools error: EACCES: permission denied

I am trying to deploy Firebase hosting of my web app.
At the command line, when I type firebase deploy, I get the following error.
Note: firebase deploy is just one example. The same error occurs for all firebase commands. (e.g., firebase --help, firebase -v, firebase login, firebase logout, etc.)
Error
/usr/local/lib/node_modules/firebase-tools/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/mowzer/.config/configstore/update-notifier-firebase-tools.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.create.all.get (/usr/local/lib/node_modules/firebase-tools/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/firebase-tools/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/firebase-tools/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/firebase-tools/node_modules/update-notifier/index.js:123:23)
at Object. (/usr/local/lib/node_modules/firebase-tools/bin/firebase:5:48)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Everything I have tried so far (including every CLI firebase instruction) rejects me for lack of access.
What can I do? What should I try?
(I am on a Mac OSX Yosemite v10.10.5 and firebase-tools v3.0.3)
Edit: When I do sudo firebase deploy, I get the following error.
Error: The entered credentials were incorrect.
I tried the following solution.
I tried to delete problem files then reinstall firebase-tools.
Terminal.sh
cd
cd .config/configstore
# Delete problematic files
rm firebase-tools.json
override rw------- root/staff for firebase-tools.json? y
rm update-notifier-firebase-tools.json
override rw------- root/staff for update-notifier-firebase-tools.json? y
# Reinstall firebase-tools
cd
sudo npm install -g firebase-tools
Then...
cd path/to/directory
cd firebase deploy
Now this file generates the error:
/usr/local/lib/node_modules/firebase-tools/node_modules/configstore/index.js:53
cd /usr/local/lib/node_modules/firebase-tools/node_modules/configstore
I fix it by adding sudo at the beginning of the command line!
This looks like an issue with the permissions of modules you have npm installed. This is something lots of developers run into, and npm actually has some documentation on how to resolve it. Once you go through that, try again (you may need to re-install firebase-tools) and things should work.
I had the same issue, and I fixed it by using this command curl -sL firebase.tools | upgrade=true bash
Add sudo prior to command it should work
sudo npm -g i firebase-tools
I had the same issue, and I fixed it by doing chmod 755 on all the files in the configstore directory
Expanding more detail to the solution provided by #jacobawenger:
The most robust solution is to install Homebrew and let Homebrew manage the npm package installation for you.
Terminal.sh
# EACCESS error reference: https://docs.npmjs.com/getting-started/fixing-npm-permissions
# Install Homebrew # Reference: brew.sh # Ensures NPM is installed properly to avoid EACCESS errors
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install npm # Reference: brew.sh
brew install node
# Install firebase-tools
npm install -g firebase-tools # Non-recurring task # Also updates to newest version (see notice)
Easy Way:
Back up your computer.
if you have Permission issue run first this
sudo chown -R $USER /usr/local/lib/node_modules
then 2nd
1)- mkdir ~/.npm-global
2)- npm config set prefix '~/.npm-global'
3)- export PATH=~/.npm-global/bin:$PATH
4)- source ~/.profile
5)- npm install -g jshint
6)- NPM_CONFIG_PREFIX=~/.npm-global
You can try using the --unsafe-perm flag. Just like this:
sudo npm install -g firebase-tools --unsafe-perm
Try run the command as
su root
if you are using ubuntu.
For me, just use sudo, did not work.
I'm using Ubuntu 18.x.x and I was trying install firebase through npm
What worked for me was basically reinstalling the node using the node version manager.
For this, you just install latest node js version this way
In my case at the point of this reply, the LTS Version of the Node JS is v14.17.0 hence nvm use 14.17.0 now try re-running the build.
i faced the same issue recently.
running this command solved the issue for me
sudo chown -R $USER ~/.config/configstore
There's information explaining why the sudo command makes the difference, and generally, when we are calling commands in terminal mode, we are not recognised as the computer's administrator, whereas certain commands are reserved for the administrator only. The sudo command enables terminal commands to be executed as the administrator. You can read about the sudo command here : )
Thank you for your contributions towards resolving this issue.

Resources