Upon running npm run dev
after having installed next 9.0
, the above mentioned error is generated.
Steps to reproduce the behavior, please provide code snippets or a repository:
位 npm run dev
> [email protected] dev C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend
> set NODE_ENV=development&&node server.js
> Using external babel configuration
> Location: "C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\package.json"
[ error ] ./node_modules/next/dist/client/next-dev.js 23:6
Module parse failed: Unexpected token (23:6)
You may need an appropriate loader to handle this file type.
|
|
> import('./dev/noop'); // Support EventSource on Internet Explorer 11
|
| if (!window.EventSource) {
> Ready on http://localhost:7777
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ error ] ./node_modules/next/dist/client/next-dev.js 23:6
Module parse failed: Unexpected token (23:6)
You may need an appropriate loader to handle this file type.
|
|
> import('./dev/noop'); // Support EventSource on Internet Explorer 11
|
| if (!window.EventSource) {
{ Error: Cannot find module 'C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\.next\build-manifest.json'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.loadComponents (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next-server\dist\server\load-components.js:21:9)
at DevServer.findPageComponents (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next-server\dist\server\next-server.js:285:40)
at DevServer.renderErrorToHTML (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next-server\dist\server\next-server.js:349:35)
at DevServer.renderErrorToHTML (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next\dist\server\next-dev-server.js:15:466)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7) code: 'MODULE_NOT_FOUND' }st.json'
Expected dev server to be launched
package.json
"scripts": {
"dev": "set NODE_ENV=development&&node server.js",
"build": "next build",
"start": "pm2-runtime start ecosystem.config.js --env production",
"test": "set NODE_ENV=test&& jest --watch",
"heroku-postbuild": "./node_modules/next/dist/bin/next build"
},
server.js
const port = parseInt(process.env.PORT, 10) || 7777
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
server.use((req, res, next) => {
res.setHeader('Cache-Control', 'public, must-revalidate, max-age: 86400, s-maxage=86400, stale-while-revalidate=86400');
next()
});
csp(server);
server.use(helmet());
server.use(helmet.referrerPolicy({ policy: 'same-origin' }));
server.use(helmet.featurePolicy({
features: {
fullscreen: ["'self'"],
vibrate: ["'none'"],
payment: ['https://stripe.com'],
syncXhr: ["'self'"],
geolocation: ["'self'"]
}
}));
const ssrCache = cacheableResponse({
ttl: 1000 * 60 * 60, // 1hour
get: async ({ req, res, pagePath, queryParams }) => ({
data: await app.renderToHTML(req, res, pagePath, queryParams)
}),
send: ({ data, res }) => res.send(data)
})
app.prepare().then(() => {
server.get('*', function(req,res,next) {
if(req.headers['x-forwarded-proto'] != 'https' && process.env.NODE_ENV === 'production')
res.redirect('https://'+req.hostname+req.url)
else
next()
});
server.get('/', (req, res) => ssrCache({ req, res, pagePath: '/' }));
server.get('*', (req, res) => handle(req, res));
server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`);
})
})
Please try removing your .next/
directory and building again.
We cannot reproduce this error without a full reproduction. Please provide a full reproduction if the above suggestion does not work.
Looks like many people ran into this issue based on the votes. I would post a reproduction, but the code is proprietary at the moment.
Looks like many people ran into this issue based on the votes. I would post a reproduction, but the code is proprietary at the moment.
How's it man
Most helpful comment
Please try removing your
.next/
directory and building again.