Пишет ошибку функций при запуске сервера?
Как можно решить данную проблему
app.js
const express = require('express')
const config = require('config')
const mongoose = require('mongoose')
const app = express()
const PORT = config.get('port') || 5000
await async function start(){
try{
await mongoose.connect(config.get('mongooseUri')),{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
}
app.listen(PORT, console.log('App has been app on ${PORT}'))
} catch(e){
console.log('Server error', e.massage)
process.exit(1)
}
}
start()
package.json
{
"dependencies": {
"config": "^3.3.8",
"express": "^4.18.2",
"mongoose": "^6.6.7"
},
"devDependencies": {
"concurrently": "^7.5.0",
"nodemon": "^2.0.20"
},
"name": "mearn",
"version": "1.0.0",
"description": "stack",
"main": "app.js",
"scripts": {
"start": "node app.js",
"server": "nodemon node app.js"
},
"keywords": [
"mearn",
"react"
],
"author": "level",
"license": "ISC"
}
вот что выводит консоль
await async function start(){
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
[nodemon] app crashed - waiting for file changes before starting