I am getting this error when running firebase init functions in terminal
这是我用来调用firebase的firebase.js代码:
import * as firebase from '@firebase/app' //line 1 which seems to cause the error
//imports for webonly
const Firebase = firebase.initializeApp(firebaseConfig);
export default Firebase
我也曾尝试从'firebase'和'react-native-firebase / app'导入firebase,但是当尝试在firebase中使用cloud函数和firebase初始化函数时,我在链接中遇到了错误
如果有人可以提供帮助,将不胜感激。 谢谢。另外,如果重要的话,我在博览会上使用react-native
编辑:所有firebase命令均不起作用,并给出相同的错误 这是错误:SyntaxError:无法在模块外部使用import语句
依赖项:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@firebase/auth": "^0.14.3",
"@firebase/messaging": "^0.6.13",
"@react-native-community/masked-view": "0.1.5",
"@react-native-firebase/app": "^6.4.0",
"@react-native-firebase/messaging": "^6.4.0",
"@react-navigation/compat": "^5.1.7",
"@react-navigation/drawer": "^5.3.4",
"@react-navigation/native": "^5.1.4",
"@react-navigation/stack": "^5.2.1",
"expo": "~36.0.0",
"expo-background-fetch": "~8.0.0",
"expo-task-manager": "^8.1.0",
"fcm-node": "^1.5.2",
"firebase": "^7.14.1",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.0",
"native-base": "^2.13.8",
"path": "^0.12.7",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-filesystem": "^0.1.0",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "~1.5.0",
"react-native-paper": "^3.6.0",
"react-native-reanimated": "~1.4.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7",
"react-navigation-material-bottom-tabs": "^2.2.6",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-preset-expo": "~8.0.0",
"@babel/core": "^7.0.0"
},
"private": true
}
解决方案:我不确定这是否符合答案,但是通过使默认shell git BASH能够执行命令
答案 0 :(得分:0)
您可以按以下方式导入:
import * as firebase from 'firebase';