gpt4 book ai didi

javascript - Firebase 存储在 Express 服务器环境中不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:42:28 26 4
gpt4 key购买 nike

我目前正在构建一个应用程序并尝试测试我使用 Express 创建的生产服务器环境。当通过 webpack-dev-server 服务时,应用程序工作正常,但是当我的 Express server.js 被 webpack 捆绑,并且 node server.bundle.js 运行时,我得到关于 Firebase 存储的以下错误。

/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:533
var storage = _firebaseConfig2.default.storage();
^

TypeError: _firebaseConfig2.default.storage is not a function

Node 最终只是切换到运行我的开发环境。

下面是我的 package.json,其中包含我的依赖项和 npm 脚本,后跟来 self 的终端的日志。

我在“_firebaseConfig2.default.storage is not a function”上进行的所有 google/stackoverflow 搜索几乎没有结果。

Package.json

{
"name": "mtbparks-member-app",
"version": "0.1.0",
"main": "index.html",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:dev": "webpack-dev-server --inline --content-base build/ --history-api-fallback && postcss --use autoprefixer -d build src/styles.css",
"start:prod": "npm run build && node server.bundle.js",
"build:client": "webpack && postcss --use autoprefixer -d build src/styles.css",
"build:server": "webpack --config webpack.server.config.js",
"build": "npm run build:client && npm run build:server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"devDependencies": {
"autoprefixer": "^6.3.6",
"babel-core": "^6.8.0",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.9.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"eslint": "^2.9.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^5.1.1",
"http-server": "^0.9.0",
"postcss-cli": "^2.5.2",
"postcss-loader": "^0.9.1",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"compression": "^1.6.2",
"express": "^4.13.4",
"firebase": "3.0.2",
"foundation-sites": "^6.2.1",
"if-env": "^1.0.0",
"re-base": "^1.5.1",
"react": "^15.0.2",
"react-dom": "^15.0.2",
"react-router": "^2.4.0"
}
}

日志

=> NODE_ENV=production npm start

> mtbparks-member-app@0.1.0 start /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev


> mtbparks-member-app@0.1.0 start:prod /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> npm run build && node server.bundle.js


> mtbparks-member-app@0.1.0 build /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> npm run build:client && npm run build:server


> mtbparks-member-app@0.1.0 build:client /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> webpack && postcss --use autoprefixer -d build src/styles.css

Hash: cf9ca8bbc1315fc1c9db
Version: webpack 1.13.0
Time: 14624ms
Asset Size Chunks Chunk Names
bundle.js 855 kB 0 [emitted] main
bundle.js.map 4.59 MB 0 [emitted] main
[0] multi main 40 bytes {0} [built]
+ 538 hidden modules

> mtbparks-member-app@0.1.0 build:server /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> webpack --config webpack.server.config.js

Hash: 4561926734ef8e1e5a47
Version: webpack 1.13.0
Time: 973ms
Asset Size Chunks Chunk Names
server.bundle.js 27.6 kB 0 [emitted] main
[0] multi main 40 bytes {0} [built]
+ 17 hidden modules
/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:533
var storage = _firebaseConfig2.default.storage();
^

TypeError: _firebaseConfig2.default.storage is not a function
at Object.defineProperty.value (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:533:41)
at __webpack_require__ (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:20:30)
at Object.defineProperty.value (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:179:14)
at __webpack_require__ (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:20:30)
at Object.<anonymous> (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:83:16)
at Object.<anonymous> (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:121:31)
at __webpack_require__ (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:20:30)
at Object.<anonymous> (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:48:19)
at __webpack_require__ (/Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:20:30)
at /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/server.bundle.js:40:18

npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/palcisto/.nvm/versions/node/v5.11.1/bin/node" "/Users/palcisto/.nvm/versions/node/v5.11.1/bin/npm" "run" "start:prod"
npm ERR! node v5.11.1
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! mtbparks-member-app@0.1.0 start:prod: `npm run build && node server.bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mtbparks-member-app@0.1.0 start:prod script 'npm run build && node server.bundle.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mtbparks-member-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build && node server.bundle.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mtbparks-member-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mtbparks-member-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/npm-debug.log

> mtbparks-member-app@0.1.0 start:dev /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp
> webpack-dev-server --inline --content-base build/ --history-api-fallback && postcss --use autoprefixer -d build src/styles.css

http://localhost:8080/
webpack result is served from /
content is served from /Users/palcisto/Sites/sandbox/MTBparks/MTBparksMemberApp/build
404s will fallback to /index.html
Hash: e38d4972b9458e39b46c
Version: webpack 1.13.0
Time: 16461ms
Asset Size Chunks Chunk Names
bundle.js 928 kB 0 [emitted] main
bundle.js.map 5.17 MB 0 [emitted] main

最佳答案

这里是 Firebase 存储开发人员:

Firebase 存储目前仅支持浏览器 JS。自 Google Cloud Storage已经提供了许多高质量的客户端库,我们不想重新实现另一个——我们建议使用 GCloud-Node用于此类开发的库。您可以将其与现有存储桶和典型的 Firebase Server 一起使用开发设置说明。

关于javascript - Firebase 存储在 Express 服务器环境中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37394230/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com