nodejs TypeError: Object prototype may only be an Object or null
При попытке запустить проект в production режиме на хостинге, происходит ошибка. В чем может быть проблема? На локальном сервере в development режиме все нормально запускается.
Ошибка:
root@cyber-insurance-diploma-project:~/cyber-insurance-diploma-project# npm run start
> [email protected] start /root/cyber-insurance-diploma-project
> cross-env NODE_ENV=production node app.js
/root/cyber-insurance-diploma-project/node_modules/serve-static/index.js:48
var opts = Object.create(options || null)
^
TypeError: Object prototype may only be an Object or null: client
at Function.create (<anonymous>)
at Function.serveStatic [as static] (/root/cyber-insurance-diploma-project/node_modules/serve-static/index.js:48:21)
at Object.<anonymous> (/root/cyber-insurance-diploma-project/app.js:18:24)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `cross-env NODE_ENV=production node app.js`
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-12-15T16_57_28_906Z-debug.log
root@cyber-insurance-diploma-project:~/cyber-insurance-diploma-project#
scripts from package.json:
"scripts": {
"start": "cross-env NODE_ENV=production node app.js",
"server": "nodemon app.js",
"client": "npm run start --prefix client",
"client:install": "npm install --prefix client",
"client:build": "npm run build --prefix client",
"dev": "cross-env NODE_ENV=development concurrently \"npm run server\" \"npm run client\""
},
Фрагмент app.js:
if (process.env.NODE_ENV === 'production') {
app.use('/', express.static(path.join(__dirname), 'client', 'build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}