2017-10-19 27 views
6

Gần đây tôi đã bắt đầu nhận được lỗi bên dưới khi cố gắng triển khai Firebase (sau khi đã thực hiện thành công trong quá khứ). Tôi không chắc chắn những gì có thể đã thay đổi cho điều này để bắt đầu xảy ra. Nếu tôi chạy firebase phục vụ để phục vụ trên localhost, mọi thứ hoạt động tốt. Package.json của tôi và yêu cầu từ index.js cũng ở dưới đây.Lỗi triển khai Firebase: Không thể tìm thấy mô-đun 'firebase-admin'

i deploying functions, hosting 
i functions: ensuring necessary APIs are enabled... 
i runtimeconfig: ensuring necessary APIs are enabled... 
+ runtimeconfig: all necessary APIs are enabled 
+ functions: all necessary APIs are enabled 
i functions: preparing functions directory for uploading... 
i functions: packaged functions (46.02 KB) for uploading 
+ functions: functions folder uploaded successfully 
i hosting: preparing public directory for upload... 
! Warning: Public directory does not contain index.html 
+ hosting: 9 files uploaded successfully 
i starting release process (may take several minutes)... 
i functions: updating function app... 
! functions[app]: Deploy Error: Function load error: Code in file index.js can't be loaded. 
Did you list all required modules in the package.json dependencies? 
Detailed stack trace: Error: Cannot find module 'firebase-admin' 
at Function.Module._resolveFilename (module.js:469:15) 
at Function.Module._load (module.js:417:25) 
at Module.require (module.js:497:17) 
at require (internal/module.js:20:19) 
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/apps.j 
s:25:16) 
at Module._compile (module.js:570:32) 
at Object.Module._extensions..js (module.js:579:10) 
at Module.load (module.js:487:32) 
at tryModuleLoad (module.js:446:12) 
at Function.Module._load (module.js:438:3) 


Functions deploy had errors. To continue deploying other features (such as datab 
ase), run: 
firebase deploy --except functions 

Error: Functions did not deploy properly. 

package.json:

{ 
"name": "functions", 
"description": "Cloud Functions for Firebase", 
"dependencies": { 
"@google-cloud/vision": "^0.12.0", 
"async": "^2.5.0", 
"consolidate": "^0.14.5", 
"express": "^4.15.4", 
"firebase-admin": "^5.4.0", 
"firebase-functions": "^0.5.7", 
"handlebars": "^4.0.10", 
"jquery": "^3.2.1", 
"js-levenshtein": "^1.1.3", 
"json-query": "^2.2.2" 
}, 
"private": true 
} 

Từ index.js:

const functions = require('firebase-functions'); 
const firebase = require('firebase-admin'); 
const express = require('express'); 
const engines = require('consolidate'); 
const Vision = require('@google-cloud/vision'); 
const levenshtein = require('js-levenshtein'); 
const restName = require('./restName'); 
const parser = require('./parser'); 
const jsonQuery = require('json-query') 

const firebaseApp = firebase.initializeApp(
functions.config().firebase 
); 
+0

Chỉ mới bắt đầu nhận được cùng một lỗi –

Trả lời

12

Họ có một gián đoạn dịch vụ hoạt động. Làm theo này cho một workaround: https://status.firebase.google.com/incident/Functions/17024

Chạy các lệnh sau bên trong kho lưu trữ chức năng:

npm install --save-exact [email protected] npm install --save-exact [email protected] 

Sau đó thử triển khai chức năng một lần nữa:

firebase deploy --only functions 

Nếu NPM không làm việc, bạn có thể thử sợi làm việc cho chúng tôi:

yarn add [email protected] --exact yarn add [email protected] --exact 
+0

Tôi đã rất thất vọng, cảm ơn bạn vì điều này! – user1819575

+0

Nó hoạt động! Cảm ơn! Và cảm ơn đôi cho gợi ý sợi! npm sẽ không cài đặt nó do "Công cụ không được hỗ trợ cho [email protected]: muốn: {" nút ":" ~ 0.10.12 "} (hiện tại: {" nút ":" 6.11.1 "," npm ": "5.5.1"}) " – Motin

+0

dường như được cố định trên mặt của tôi (Na Uy) ... không phải npm cũng như giải pháp thay thế sợi làm việc cho tôi. –

2

Cập nhật tệp package.json trong chức năng thư mục và nhìn vào phụ thuộc loại bỏ dấu ~ từ căn cứ hỏa lực-admin và^từ căn cứ hỏa lực chức năng nó nên được như thế:

"dependencies": { 
    "firebase-admin": "5.4.0", 
    "firebase-functions": "0.7.0" 
} 

trong kiểu dòng lệnh

npm install

và sau đó cố gắng triển khai một lần nữa.

0

Tôi cũng gặp lỗi tương tự. tôi sửa lỗi đó khi cài đặt phiên bản khác nhau trong nút. Tôi gỡ cài đặt phiên bản mới của mình và tôi cài đặt Nút v7.8.0. sau đó nó hoạt động tốt :)

0

Tôi đã đi đến thư mục chức năng và chạy yarn (hoặc npm install nếu bạn là trường học cũ). Sau đó quay trở lại thư mục dự án của tôi và chạy lại firebase deploy.

Các vấn đề liên quan