Ошибка запуска на сервере проекта Next.js
Проблема в следующем - сделал небольшой проект (2.5 страницы) на Next.js решил проверить как это все дело работает на сервере. Сделал все по инструкции.
Суть проблемы:
При первом запуске командой npm run start проект запускается, работает, доступ через браузер есть. Но если проект остановить и перезапустить получаю ошибку
TypeError: a.removeHeader is not a function
at SendStream.removeContentHeaderFields (/home/dzi/website/node_modules/next/dist/compiled/send/index.js:1:5160)
at SendStream.notModified (/home/dzi/website/node_modules/next/dist/compiled/send/index.js:1:5273)
at SendStream.send (/home/dzi/website/node_modules/next/dist/compiled/send/index.js:1:7976)
at onstat (/home/dzi/website/node_modules/next/dist/compiled/send/index.js:1:8914)
at FSReqCallback.oncomplete (fs.js:184:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `next start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
С pm2 такая же беда, бьет сервис и перезапускается - заходишь на страницу - умирает и опять перезапускается, в лог попадает следующее:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/bin/node',
1 verbose cli '/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/dzi/website/node_modules/.bin:/usr/local>
9 verbose lifecycle [email protected]~start: CWD: /home/dzi/website
10 silly lifecycle [email protected]~start: Args: [ '-c', 'next start' ]
11 silly lifecycle [email protected]~start: Returned: code: 1 signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `next start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/dzi/website
16 verbose Linux 5.4.0-26-generic
17 verbose argv "/usr/bin/node" "/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js" "start"
18 verbose node v14.15.1
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `next start`
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Помогите плиз, для меня это первый опыт запуска проекта на Next.js. Из исходного кода не знаю что может помочь, но думаю что проблема может быть в файлах настроек
package.json
{
"name": "nexjs-format-app",
"version": "0.0.1",
"description": "Online market",
"main": "_app.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [
"market",
"format"
],
"author": "Dz",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.5.3",
"firebase": "^8.0.1",
"next": "^10.0.1",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-icons": "^3.11.0",
"react-redux": "^7.2.2",
"redux": "^4.0.5"
}
}
next.config.js
module.exports = {
trailingSlash: true,
distDir: 'build'
}
Сервер Ubuntu 20.04 x64, 1 ядро, 1гиг RAM