我正在使用Ubuntu 18.04 我试图通过“ npm start”运行npm。 我收到上述错误。 任何人都可以帮助我解决此错误。
`
WARNING: Adonis has detected an unhandled promise rejection, which may
cause undesired behavior in production.
To stop this warning, use catch() on promises or wrap await
calls inside try/catch.
RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received NaN.
at lookupAndConnect (net.js:938:13)
at Socket.connect (net.js:914:5)
at Object.connect (net.js:162:17)
at makeConnection (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/connect.js:270:20)
at makeConnection (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/connect.js:36:7)
at callback (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/connect.js:260:5)
at makeConnection (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/connect.js:273:12)
at connect (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/connect.js:34:10)
at Pool.connect (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/connection/pool.js:548:3)
at Server.connect (/home/bhagya/foodmonk/node_modules/mongodb-core/lib/topologies/server.js:498:15)
at Server.connect (/home/bhagya/foodmonk/node_modules/mongoose/node_modules/mongodb/lib/topologies/server.js:360:25)
at createServer (/home/bhagya/foodmonk/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:350:10)
at parseFn (/home/bhagya/foodmonk/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:245:14)
at parseHandler (/home/bhagya/foodmonk/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:134:38)
at module.exports (/home/bhagya/foodmonk/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:25:12)
at deprecated (internal/util.js:71:15)
`
下面是我的环境文件:
`HOST=127.0.0.1
PORT=3333
NODE_ENV=development
APP_URL=http://${HOST}:${PORT}
CACHE_VIEWS=false
APP_KEY=xyavbcd
SESSION_DRIVER=cookie
HASH_DRIVER=bcrypt
DB_CONNECTION=mongodb
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_USER=
MONGO_PASSWORD=
MONGO_DATABASE=xyz`
答案 0 :(得分:0)
首先确认你的.env
和它的初始化,这个问题是由于没有提供redis_host或者redis_url或者redis_port等...
所以我们应该采取以下步骤: