简体   繁体   中英

Firebase Functions npm install is always stuck

I am trying to host a node app using firebase functions. Now everything works fine. I run the command

firebase init functions

Then I follow the steps. (Firebase tools are correctly installed).

Then after some steps it asks me to

Do you want to install dependencies with npm now? Yes

I say yes and then it does something at at a point it is stuck.

This is the screenshot

在此处输入图片说明

The solutions I tried.

I tried running the following command on functions folder

npm install --verbose

It doesn't displays any clue as well here is the screenshot.

在此处输入图片说明

I also tried reinstalling node, reinstalling the whole firebase cli. I cleared npm cache and tried. Nothing work so far.

Here is my package.json file.

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~6.0.0",
    "firebase-functions": "^2.1.0"
  },
  "private": true
}

Any help would be appreciated. Thank You

Your version of Node.js on your development machine is bad. Do this:

nvm install 8.6.1
nvm alias default 8.6.1

Then nail Firebase Functions Node.js runtime to version 8 by adding this to your package.json file inside your functions folder:

  "engines": {
    "node": "8"
  },

I see you tried using node 10.15.0 and 11.6.0, but neither of them is currently supported by Google Cloud Functions.

The currently supported versions are Node.js 6 (6.14.0) and Node.js 8 (8.14.0), so I suggest you use one of them to setup your project's runtime (just bear in mind that the Node.js 8 runtime is still beta). You can check out complete and updated info about Cloud Functions supported runtimes here .

So what I suggest you try is using one of these node versions to install firebase-tools and them setup your project. For example, for Node.js 6.14.0:

# install node.js 6.14.0 version (if you don't have it already)
$ nvm install 6.14.0

# use node.js 6.14.0 version
$ nvm use 6.14.0

# install firebase cli
$ npm install -g firebase-tools

# login with your google credentials
$ firebase login

# init your project
$ firebase init functions

Important: if your project's directory already has a node_modules folder, delete it before running firesbase init functions .

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