मुझे काम करने के लिए फायरबेस 3.0.1 प्राप्त करने में कोई समस्या है। मुझे लगता है कि यह मेरे वेबपैक सेटअप के संबंध में है। मेरी फाइलें नीचे हैं। जब webpack डेव सर्वर के साथ अपने एप्लिकेशन चल रहा त्रुटि मिलती है:वेबपैक आयात फ़ायरबेस काम नहीं कर रहा
Uncaught TypeError: firebase.initializeApp is not a function
दिलचस्प बात यह है कि अगर मैं var firebase = require('firebase');
के बाद एक debugger;
या ब्रेकप्वाइंट डाल यह एक खाली वस्तु प्रतीत हो रहा है है।
webpack.config.js
const webpack = require("webpack");
module.exports = {
entry: './src/index.js',
output: {
path: 'public',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015&presets[]=react'
}]
},
plugins: process.env.NODE_ENV === 'production' ? [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()
] : []
};
package.json
{
"name": "burn",
"version": "1.0.0",
"description": "burn messaging",
"main": "index.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:dev": "webpack-dev-server --inline --content-base public --history-api-fallback",
"start:prod": "webpack && firebase deploy"
},
"author": "James Gilchrist <[email protected]>",
"license": "ISC",
"dependencies": {
"compression": "^1.6.2",
"express": "^4.13.4",
"firebase": "^3.0.1",
"if-env": "^1.0.0",
"react": "^15.0.2",
"react-dom": "^15.0.2",
"react-router": "^2.4.0"
},
"devDependencies": {
"babel-core": "^6.9.0",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1"
}
}
index.js
var firebase = require('firebase');
var config = {
apiKey: "AIzaSyA9gUmSBu4SZ4P9H_4lXuN1ouD_GBKq3aw",
authDomain: "burn-56840.firebaseapp.com",
databaseURL: "https://burn-56840.firebaseio.com",
storageBucket: "burn-56840.appspot.com"
};
firebase.initializeApp(config);
आप जानते हैं। मैंने देखा कि फायरबेस में दस्तावेज में वह विकल्प था। लेकिन यह बहुत मूर्खतापूर्ण लग रहा था मैंने कोशिश भी नहीं की। शीघ्र जवाब देने के लिए ध्न्यवाद; बहुत सराहना की। –