Обычно я использую nodejs на windows. Но теперь я клонирую мое приложение nodejs на Raspberry Pi и начинаются проблемы.
Приложение работает, когда:
>> cd /home/dietpi/programs/esp32-node-server && npm start
И не работает:
>> sudo node /home/dietpi/programs/esp32-node-server/index.js
Ошибка:
/home/dietpi/programs/my-project/node_modules/mongoose/lib/connection.js:579
throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
^
Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
at new MongooseError (/home/dietpi/programs/esp32-node-server/node_modules/mongoose/lib/error/mongooseError.js:10:11)
at NativeConnection.Connection.openUri (/home/dietpi/programs/esp32-node-server/node_modules/mongoose/lib/connection.js:579:11)
at Mongoose.connect (/home/dietpi/programs/esp32-node-server/node_modules/mongoose/lib/index.js:333:15)
at Object.<anonymous> (/home/dietpi/programs/esp32-node-server/app.js:17:10)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/dietpi/programs/esp32-node-server/index.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
message: 'The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.',
name: 'MongooseError'
}
Приложение имеет следующий пакет. json:
"name": "esp32-node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"watch": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "JK",
"license": "ISC",
"dependencies": {
"bcrypt": "^3.0.2",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.8.11",
"mongoose-unique-validator": "^2.0.3",
"morgan": "^1.9.1"
},
"devDependencies": {
"eslint": "^6.8.0",
"nodemon": "^2.0.2"
},
"engines": {
"node": ">=6.0.0"
}
}
Что вызывает это? Некоторые базовые c linux разрешения? Или что?