Hi I am unable to deploy functions using firebase, I am getting the below error. On trying to look at the logs could not find anything concrete.
I tried following the steps given in the below link : NPM Error : Error: EROFS: read-only file system, mkdir '/npm'
but was not able to if someone can please provide the clear steps
If someone can please help me to resolve this issue.
Below are the necessary details.
error displayed :
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
app(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions
On running function:log got the below :
2022-09-26T10:16:48.103137Z ? app: Detailed stack trace: Error: EROFS: read-only file system, mkdir '/workspace/Users'
2022-09-26T10:16:48.103147Z ? app: at Object.mkdirSync (node:fs:1386:3)
2022-09-26T10:16:48.103157Z ? app: at sync (/workspace/node_modules/mkdirp/index.js:74:13)
2022-09-26T10:16:48.103165Z ? app: at sync (/workspace/node_modules/mkdirp/index.js:80:24)
2022-09-26T10:16:48.103173Z ? app: at sync (/workspace/node_modules/mkdirp/index.js:80:24)
2022-09-26T10:16:48.103181Z ? app: at sync (/workspace/node_modules/mkdirp/index.js:80:24)
2022-09-26T10:16:48.103192Z ? app: at Function.sync (/workspace/node_modules/mkdirp/index.js:80:24)
2022-09-26T10:16:48.103205Z ? app: at new DiskStorage (/workspace/node_modules/multer/storage/disk.js:21:12)
2022-09-26T10:16:48.103214Z ? app: at module.exports (/workspace/node_modules/multer/storage/disk.js:65:10)
2022-09-26T10:16:48.103222Z ? app: at new Multer (/workspace/node_modules/multer/index.js:15:20)
2022-09-26T10:16:48.103230Z ? app: at multer (/workspace/node_modules/multer/index.js:95:12)
2022-09-26T10:16:48.103237Z ? app: Could not load the function, shutting down.
2022-09-26T10:16:48.776575003Z E app: Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging
index.js
const functions = require("firebase-functions");
// const admin = require('firebase-admin');
// admin.initializeApp();
const express = require('express');
require('./db/mongoose');
//require('../db/mongoose');
//const notification = require('./db/models/notification');
var bodyParser = require('body-parser');
const app = express();
const multer = require('multer');
const jwt = require('jsonwebtoken');
const http = require('http').createServer(app);
let fs = require('fs');
require('dotenv').config();
const filterPage = require('./routers/filter');
var cors = require("cors");
var cookieParser = require('cookie-parser');
var path = require('path');
const issueRaiseUser = require('./routers/user_issue');
const googleStorage = require('@google-cloud/storage');
app.use(cors());
const portCheck = process.env.PORT || 3001
app.use(express.json({limit: "50mb"}));
app.use(express.urlencoded({limit: "50mb", extended: true}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, '../pixNodes/public-flutter')));
app.get('/', (_, res) => {
res.sendFile(path.resolve(__dirname, '../pixNodes/public-flutter/index.html'));
});
exports.app = functions.https.onRequest(app);
on running npm root -g got the below output :
/Users/akm/.npm-global/lib/node_modules