When I try to run a node program,it throwed a error,the error code is 4058 - mkdir

When I try to run a node program.
fs.mkdir("E:\\test\\1",function(err){
console.log(err);
if(err) throw err;
console.log('创建文件夹成功')
})
However, it throws an error as below
error information is "[Error:ENOENT,mkdir 'E:\test\1 ]
errno:-4058,code:'ENOENT',path:'E:\\test\\1'".

Related

open failed: ENOENT (No such file or directory) Attempt to call getDuration in wrong state: mPlayer=0x0, mCurrentState=0

I download audio from server then I want to play it with MediaPlayer
*mediaPlayer = MediaPlayer()
try {
mediaPlayer.setDataSource(songPath)
mediaPlayer.prepare()
mediaPlayer.start()
initSeekBarAndDuration()
} catch (e: Exception) {
}*
but this errors
error (-38, 0)
Attempt to call getDuration in wrong state: mPlayer=0x0, mCurrentState=0
show in log cat. However, In storage that file have, it work perfectly with other musicplayer.
How to solve it, Please share me solutions.

Reference Error with module exports event discord.js

I am very confused by this error. In my code I have /events/ and /commands/ this is in /events/ I made sure that everything else works but this I can't figure out. The code down below is meant to work as a server count for a website. Anybody know? Thank you.
const Discord = require('discord.js');
var db = require('mysql');
var con = db.createConnection({
host: "localhost",
user: "",
password: "",
database: ""
});
module.exports = (client, guildCreate) => {
//welcome embed
const welcomeEmbed = new Discord.MessageEmbed()
.setColor('#858884')
.setTitle('Hello!')
.setAuthor('DHL Bot', 'https://cdn.discordapp.com/app-icons/708717412391845988/967e1b05f7b8aeca1d6b4649dc5530c8.png')
.setDescription(`Hello I am DHL, I am devoloped by Den#0762. Please do !setup. For support you can join our support server https://discord.com/invite`)
.setTimestamp()
.setFooter('By: Den#0762', 'https://cdn.discordapp.com/avatars/407206318911258628/e972b589e0ea4c45064d39b0380d77fd.png')
guild.owner.send(welcomeEmbed)
//db for scount
con.connect(function(err) {
if (err) throw err;
var sql = "UPDATE scount SET servercount = servercount + 1";
con.query(sql, function (err, result) {
console.log(result.affectedRows + " new server");
});
});
}
(node:1949) UnhandledPromiseRejectionWarning: ReferenceError: guild is not defined
at module.exports (/root/dc/DHL/events/guildCreate.js:23:1)
at Client.emit (events.js:315:20)
at Object.module.exports [as GUILD_CREATE] (/root/node_modules/discord.js/src/client/websocket/handlers/GUILD_CREATE.js:33:14)
at WebSocketManager.handlePacket (/root/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/root/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/root/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/root/node_modules/ws/lib/event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (/root/node_modules/ws/lib/websocket.js:797:20)
at Receiver.emit (events.js:315:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1949) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1949) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
You're referencing guild, but it isn't declared. Based on other code I've seen, I think you need something along these lines:
module.exports = (client, guildCreate) => {
//welcome embed
const welcomeEmbed = new Discord.MessageEmbed() [...]
client.on("guildCreate", guild => {
guild.owner.send(welcomeEmbed)
});
[...]

Getting error code 500 no matter what error I send from express using a error handler?

Using a custom error handler, specifically ts-custom-error but even when I roll my own, if I throw the following error after my routes to handle when someone puts in the wrong url/endpoint
app.use((req, res, next) => {
throw HttpError.fromCode(404)
});
app.listen(port, err => {
if (err) {
return console.error(err);
}
return console.log(`server is listening on ${port}`);
});
*edit added additional code
https://github.com/adriengibrat/ts-custom-error/blob/master/src/example/http-error.ts
I get the error message and stack ok, everything works in postman and browser for the body message, but in network on chrome and in the header it still shows a status code of 500. What am I missing?
Can you check your console/terminal for logs? 500 (Internal Server Error) means that there is something wrong with your server. Usually, an unhandled exception.
Are there any other code after this block? If not, your thrown error never gets handled anywhere, causing the 500 error.
You can use this instead:
res.status(404).send({ error: 'Your special error message here!' });

React-Native-Firebase: A network error (such as timeout, interrupted connection or unreachable host) has occurred

I'm using react-native-firebase/auth. While the code correctly logs in when online, I keep getting the following network error if offline:
A network error (such as timeout, interrupted connection or unreachable host) has occurred
How can I catch that?
import auth from '#react-native-firebase/auth'
auth().onAuthStateChanged(user => {
console.log(user)
})
auth().signInWithEmailAndPassword(email, password).catch(error => {
console.error(error);
})
I've found other similar questions, but no one seems to solve this problem.

Error to get All services and cheracteristcs from ble device using Polidea/react-native-ble-plx

Hi I am trying to connect a bluetooth device using the Polidea/react-native-ble-plx library.
First I do the scan and it works fine:
scanAndConnect() {
console.log('scanAndConnect');
this.manager.startDeviceScan(null, null, (error, device) => {
//console.log('Scanning...' + error);
if (error) {
// Handle error (scanning will be stopped automatically)
console.log('Scanning ERROR');
return;
}
if ((device.id=== '54:6C:0E:A0:7B:6D')
{
console.log('device found: ' + device.name + '(' + device.id + ')');
this.manager.stopDeviceScan();
}
}
The second step I try to connect. And it s works too!
device.connect().then((dev) => {
console.log("try to connect")
}).then((dev) => {
console.log("success to connect")
}).catch((error) => {
console.log("connect error:" + error)
throw error
});
So, now I want to get all the services and charactrists to read some informations from device, but this feature doesnt work for me.
I am using this method
device.discoverAllServicesAndCharacteristics();
And I always received an error.
Some time I receive the follow error message:
1) WARN Possible Unhandled Promise Rejection (id: 0):
BleError: Device 54:6C:0E:A0:7B:6D is not connected
I didnt understand the first one, because I have the device connected.
var status = this.manager.isDeviceConnected(device.id).then((status)=>console.log('status1: '+status))
the line above returns false before I call the connect method and it returns true after it.
But when I try to get the services and characteristics I have the message that the device isnt connected