Hello when running an application on localhost I get the following error. Before it did not happen, I modified the file server.js where the port runs, but never before had this happened to me. The port runs as seen, passes build, gulp and the page can be opened, but this has me worried, because I do not know how to find what it means and to what it should be.
I show you the server code, which is modified when the error started, because the only reference I see is the package.json
Michaelgram escuchando en el puerto 3000
[18:22:53] Using gulpfile ~/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/Gulpfile.js
[18:22:53] Starting 'watch'...
[18:22:53] Finished 'watch' after 52 ms
events.js:167
throw er; // Unhandled 'error' event
^
Error: ENOSPC: no space left on device, watch '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/package.json'
at FSWatcher.start (internal/fs/watchers.js:161:26)
at Object.watch (fs.js:1227:11)
at createFsWatchInstance (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:159:5)
Emitted 'error' event at:
at FSWatcher.emit (events.js:182:13)
at FSWatcher._handleError (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/index.js:257:10)
at createFsWatchInstance (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:39:5)
at setFsWatchListener (/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[... lines matching original stack trace ...]
at FSReqWrap.oncomplete (fs.js:159:5)'
var express = require('express')
var multer = require('multer')
var ext = require('file-extension')
var cookieParser = require('cookie-parser')
var bodyParser = require('body-parser')
var expressSession = require('express-session')
var passport = require('passport')
var michaelgram = require('michaelgram-client')
var aws = require('aws-sdk')
var multerS3 = require('multer-s3')
var config = require('./config')
var port = process.env.PORT || 3000
let client = michaelgram.createClient(config.client)
s3 = new aws.S3({
accessKeyId: config.aws.accessKey,
secretAccessKey: config.aws.secretKey
})
let storage = multerS3({
s3: s3,
bucket: 'michaelgram',
acl: 'public-read',
metadata: function (req, file, cb) {
cb(null, { fieldName: file.fieldname })
},
key: function (req, file, cb) {
cb(null, +Date.now() + '.' + ext(file.originalname))
}
})
let upload = multer({ storage: storage }).single('picture')
let app = express()
app.set(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(expressSession({
secret: config.secret,
resave: false,
saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())
app.set('view engine', 'pug')
app.use(express.static('public'))
app.get('/', function (req, res) {
res.render('index', { title: 'Michaelgram' })
})
app.get('/signup', function (req, res) {
res.render('index', { title: 'Michaelgram - Signup' })
})
app.post('/signup', function (req,res) {
let user = req.body
client.saveUser(user, function (err, usr) {
if (err) return res.status(500).send(err.message)
res.redirect('/signin')
})
})
app.get('/signin', function (req, res) {
res.render('index', { title: 'Michaelgram - Signin' })
})
app.get('/api/pictures', function (req, res, next) {
let pictures = [
{
user: {
username: 'miguelito',
avatar: ''
},
url: 'office.jpg',
likes: 0,
liked: false,
createdAt: new Date().getTime()
},
{
user: {
username: 'miguelito',
avatar: ''
},
url: 'office.jpg',
likes: 1,
liked: true,
createdAt: new Date().setDate(new Date().getDate() - 10)
}
];
setTimeout(function () {
res.send(pictures)
}, 2000)
});
app.post('/api/pictures', function (req, res) {
upload(req, res, function (err) {
if (err) {
return res.status(500).send("Error uploading file")
}
res.send('File uploaded')
})
})
app.get('/api/user/:username', (req, res) => {
const user = {
username: 'miguelito',
avatar: '',
pictures: [
]
}
res.send(user);
})
app.get('/:username', function (req, res) {
res.render('index', { title: 'Michaelgram - ${req.params.username}' })
})
app.get('/:username/:id', function (req, res) {
res.render('index', { title: 'Michaelgram - ${req.params.username}' })
})
app.listen(3000, function (err) {
if (err) return console.log('Hubo un error'), process.exit(1)
console.log('Michaelgram escuchando en el puerto 3000')
})
The lines I added were those of requiring the other module: var michaelgram = require('michaelgram-client')
that link, which I show below these lines.
Thank you very much
let client = michaelgram.createClient(config.client)
app.post('/signup', function (req,res) {
let user = req.body
client.saveUser(user, function (err, usr) {
if (err) return res.status(500).send(err.message)
res.redirect('/signin')
})
})