我目前正在关注Tyler McGinnis Tutorial,我在尝试将应用部署到Firebase时遇到了一些问题。
我在本地安装了firebase-tools(npm install --save-dev firebase-tools
),允许我托管应用程序,并在package.json中添加了几个脚本。
我正在使用npm 3.10.10和node v6.11.0
这是我的package.json:
{
"name": "github-battle",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --open",
"build": "NODE_ENV='production' webpack -p",
"firebase-init": "firebase login && firebase init",
"deploy": "npm run build && firebase deploy"
},
"babel": {
"presets": [
"env",
"react"
]
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.16.2",
"query-string": "^4.3.4",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.2"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.5.2",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.4",
"firebase-tools": "^3.9.1",
"html-webpack-plugin": "^2.29.0",
"style-loader": "^0.18.2",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.5.0"
}
}
我的webpack.config.js:
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var config = {
entry: './app/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index_bundle.js',
publicPath: '/'
},
module: {
rules: [
{ test: /\.(js)$/, use: 'babel-loader' },
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ]}
]
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.html'
})
]
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}),
new webpack.optimize.UglifyJsPlugin()
)
}
module.exports = config;
运行npm run firebase-init
时,我收到以下错误堆栈:
Error: EACCES: permission denied, open '/Users/carlosgrijalva/.config/configstore/update-notifier-firebase-tools.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at Object.get (/Users/carlosgrijalva/Code/github-battle/node_modules/configstore/index.js:34:26)
at Object.Configstore (/Users/carlosgrijalva/Code/github-battle/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/Users/carlosgrijalva/Code/github-battle/node_modules/update-notifier/index.js:34:17)
at module.exports (/Users/carlosgrijalva/Code/github-battle/node_modules/update-notifier/index.js:123:23)
at Object.<anonymous> (/Users/carlosgrijalva/Code/github-battle/node_modules/firebase-tools/bin/firebase:5:48)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "firebase-init"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! github-battle@1.0.0 firebase-init: `firebase login && firebase init`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the github-battle@1.0.0 firebase-init script 'firebase login && firebase init'.
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 github-battle package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! firebase login && firebase init
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs github-battle
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls github-battle
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/carlosgrijalva/Code/github-battle/npm-debug.log
不确定问题是否在于我正在使用的版本......有什么建议吗?
答案 0 :(得分:0)
如果您使用的是Mac或Linux,请在命令前加上sudo
。
如果您使用的是Windows,请以管理员身份运行命令提示符。