Modify a servermiddleware file
No script crash
D:\wamp64\www...\node_modules\@nuxt\builder\dist\builder.js:6160
for (const entry of dep2Entry[fileName]) {
^
TypeError: dep2Entry[fileName] is not iterable
Hi, @usb248 thanks for reporting the issue. But without repro, it is impossible to debug. Would you please share nuxt config or more details?
This evening no, tomorrow. But i can say now that i have:
serverMiddleware: [
bodyParser.json(),
bodyParser.text(),
'~/servermiddleware/cookie-session',
'~/servermiddleware/csrf',
'~/api'
],
An index.js and others directories inside api directory. @pi0 maybe a case which is not managed by HMR for server middleware (or maybe bodyParser) ?
Hi, @usb248 I tried using provided parts but could not reproduce yet. maybe because something special is inside server middleware or API?
I added a quick fix commit (4b34941df802feed93048db6429f5d4eb836f942) to ensuring entry is in the graph but seems the root cause is an entry point is not being tracked.
If you had time, would you please to debug this? Either if you can give me (privately) access to project with this problem or yourself can start by editing D:\wamp64\www...\node_modules@nuxt\builder\dist\builder.js, search for debounce((event, fileName) and log what file is missing from graph like this:
debounce((event, fileName) => {
+ if (!dep2Entry[fileName]) {
+ console.warn('HMR Entrypoint is missing but reloaded: ' + fileName)
+ return
+ }
for (const entry of dep2Entry[fileName]) {
@pi0 yes. index.js in api folder seems to cause the problem...

Content of this file :
// Create express router
import express from 'express'
const router = express.Router()
const cors = require('cors')
const urlP = require('url')
const Csrf = require('csrf')
const tokens = new Csrf()
const Multer = require('multer')
var app = express()
router.use(cors({
origin: process.env.BASE_URL,
optionsSuccessStatus: 200
}))
router.use((req, res, next) => {
Object.setPrototypeOf(req, app.request)
Object.setPrototypeOf(res, app.response)
req.res = res
res.req = req
req.query = urlP.parse(req.url, true).query
res.removeHeader('X-Powered-By')
const safeMethods = /GET|HEAD|OPTIONS|TRACE/i
if (safeMethods.test(req.method)) return next()
/* Protection CSRF */
const verify = (req) => {
return tokens.verify(req.session.csrfSecret || '', req.headers['x-csrf-token'] || '')
}
if (verify(req)) return next()
const error = new Error('Token invalide.')
error.status = 403
return next(error)
})
app.use(router)
import routes from './routes'
app.use(routes)
if(process.env.NODE_ENV === 'production') app.set('trust proxy', true)
app.use((err, req, res, next) => {
if (err) {
if (err instanceof Multer.MulterError) {
const errorMessages = {
'LIMIT_PART_COUNT': 'Trop de champs.',
'LIMIT_FILE_SIZE': 'Fichier trop volumineux.',
'LIMIT_FILE_COUNT': 'Trop de fichiers.',
'LIMIT_FIELD_KEY': 'Nom du fichier trop long.',
'LIMIT_FIELD_VALUE': 'Valeur du champ trop longue.',
'LIMIT_FIELD_COUNT': 'Trop de champs de type non fichier.',
'LIMIT_UNEXPECTED_FILE': 'Champ inattendu.'
}
if(errorMessages[err.code]) err.message = errorMessages[err.code]
}
return res.status(err.status || 422).json({ msg: (err.hasOwnProperty('message')) ? err.message : err.toString() })
}
next()
})
// Export the server middleware
export default {
path: '/api',
handler: app
}
@usb248 My most guess is that it is a windows issue. Will try on windows machine :)
let me know if this is the case.
Thanks :)
Probably windows screws up filePaths. For a temporary solutions, may install linux subsystem on windows (Will speed up dev too ;-))
Update:
This issue is happening for windows users that have a serverMiddleware registered with implicit index.js
~/api to ~/api/index.jsHi again. It should be fixed on 2.12.2 :)