【发布时间】:2020-02-13 07:20:45
【问题描述】:
我正在尝试实现用于实现 google OAuth 登录的 firestore/firebase 功能,但它一直说未导入 firebase:
代码:
ERROR in node_modules/@angular/fire/auth/auth.d.ts:4:28 - error TS2307: Cannot find module 'firebase/app'.
4 import { User, auth } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firebase.app.module.d.ts:2:74 - error TS2307: Cannot find module 'firebase/app'.
2 import { auth, database, firestore, functions, messaging, storage } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firestore/collection-group/collection-group.d.ts:2:27 - error TS2307: Cannot find module 'firebase/app'.
2 import { firestore } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firestore/collection/collection.d.ts:2:27 - error TS2307: Cannot find module 'firebase/app'.
2 import { firestore } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firestore/document/document.d.ts:5:27 - error TS2307: Cannot find module 'firebase/app'.
5 import { firestore } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firestore/firestore.d.ts:8:27 - error TS2307: Cannot find module 'firebase/app'.
8 import { firestore } from 'firebase/app';
~~~~~~~~~~~~~~
node_modules/@angular/fire/firestore/interfaces.d.ts:2:27 - error TS2307: Cannot find module 'firebase/app'.
2 import { firestore } from 'firebase/app';
~~~~~~~~~~~~~~
src/app/services/auth.service.ts:4:22 - error TS2307: Cannot find module 'firebase/app'.
4 import { auth } from "firebase/app";
~~~~~~~~~~~~~~
我尝试了什么:
我尝试重新安装@angular/fire, 我试图将“firebase/app”更改为“./firebase/app”, 我尝试在 StackOverflow 上找到解决方案,但没有。
感谢您的任何回答!
尝试:安装 Angular Firebase,但: 它是这么说的
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for grpc@1.24.0 and node@11.13.0 (node-v67 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/11.13.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase/node_modules/grpc/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase/node_modules/grpc/.node-gyp'
gyp ERR! System Linux 4.18.0-25-generic
gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
gyp ERR! cwd /usr/local/lib/node_modules/firebase/node_modules/grpc
gyp ERR! node -v v11.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/lib/node_modules/node/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/firebase/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:193:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1001:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
node-pre-gyp ERR! System Linux 4.18.0-25-generic
node-pre-gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/firebase/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/firebase/node_modules/grpc
node-pre-gyp ERR! node -v v11.13.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/lib/node_modules/node/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/usr/local/lib/node_modules/firebase/node_modules/grpc/src/node/extension_binary/node-v67-linux-x64-glibc --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
npm WARN @angular/fire@5.2.1 requires a peer of @angular/common@>=6.0.0 <9 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@5.2.1 requires a peer of @angular/core@>=6.0.0 <9 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@5.2.1 requires a peer of @angular/platform-browser@>=6.0.0 <9 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@5.2.1 requires a peer of @angular/platform-browser-dynamic@>=6.0.0 <9 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@5.2.1 requires a peer of firebase@>= 5.5.7 <7 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@5.2.1 requires a peer of rxjs@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.24.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.24.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-10-16T13_45_44_371Z-debug.log
顺便在 sudo su 中运行的命令
【问题讨论】:
标签: javascript angular firebase google-cloud-firestore