我正在使用firebase-functions
部署node.js应用程序,但是当我运行命令firebase deploy
时,我收到以下错误:
运行命令:npm --prefix $ RESOURCE_DIR运行lint 错误:EACCES:权限被拒绝,mkdir' / media / shubhamg931 / New' TypeError:无法读取属性' get'未定义的 在errorHandler(/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/utils/error-handler.js:205:17) at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/bin/npm-cli.js:83:20 在cb(/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/npm.js:224:22) at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/npm.js:262:24 at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/config/core.js:81:7 在Array.forEach() at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/config/core.js:80:13 at f(/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/once/once.js:25:25) at afterExtras(/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/config/core.js:178:20) 在Conf。 (/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/config/core.js:234:20) at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/config/set-user.js:23:20 at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53 at /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:284:29 在FSReqWrap.oncomplete(fs.js:152:21) /home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/utils/error-handler.js:205 if(npm.config.get(' json')){ ^
TypeError:无法读取属性' get'未定义的 at process.errorHandler(/home/shubhamg931/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/utils/error-handler.js:205:17) 在emitOne(events.js:115:13) at process.emit(events.js:210:7) at process._fatalException(bootstrap_node.js:349:26)
错误:函数预部署错误:命令以非零退出代码7终止
以下是我的Firebase配置文件(又名firebase.json
):
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix $RESOURCE_DIR run lint"
],
"source": "functions"
},
"hosting": {
"public": "public",
"rewrites": [{
"source": "**",
"functions": "app"
}],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
以下是我的index.js
文件:
const functions = require('firebase-functions');
var express = require("express"),
app = express(),
bodyParser = require("body-parser");
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));
app.get("/", function(req,res){
res.render("index");
});
app.get("/about", function(req,res){
console.log("ABOUT");
res.render("about");
});
app.get("/corporate", function(req,res){
console.log("CORPORATE");
res.render("corporate");
});
app.get("/weddings", function(req,res){
console.log("WEDDINGS");
res.render("wedding");
});
app.get("/parties", function(req,res){
console.log("PARTIES");
res.render("parties");
});
app.get("/contact", function(req,res){
console.log("CONTACT");
res.render("contact");
});
app.get("/detail", function(req,res){
console.log("DETAIL PAGE");
res.render("detail");
});
// app.listen(8000, function(req,res){
// console.log("started server! :)");
// });
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
exports.app = functions.https.onRequest(app);
我尝试安装nvm
,然后重新安装firebase-tools
,但这对我不起作用。
我是firebase-tools
的新手。任何帮助将不胜感激。