When I run vue's npm run dev, I got this error:
(node:10871) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3
It works fine if I run in my computer with Node 6.11.3
But fails when I deploy to AWS EC2 with Node 6.11.3, or the Latest Node 9.something
If I run with latest node, I got a detail error message:
(node:10429) UnhandledPromiseRejectionWarning: Error: Exited with code 3
at ChildProcess.cp.once.code (/home/ubuntu/loan-vue-frontend/node_modules/opn/index.js:84:13)
at Object.onceWrapper (events.js:272:13)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Socket.stream.socket.on (internal/child_process.js:353:11)
at Socket.emit (events.js:180:13)
at Pipe._handle.close [as _onclose] (net.js:541:12)
(node:10429) 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(). (rejection id: 1)
(node:10429) [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.
I have tried just installing a new project from scratch and it works.
Then I compare the code, and I found out I have this code (in a file called 'build/dev-server.js' :
var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
})
var server = app.listen(port)
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}
It seems to me the readyPromise is the cause of trouble.
But the only place that call that dev-server.js is in package.json:
"scripts": {
"dev": "node build/dev-server.js",
}
I suspect
ready: readyPromise,
is not right because 'ready' may not have a catch block. but I have no clue how I can fix it if that's the case.
Any idea?
Related
I use puppeteer-core with chrome-linux from https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1095492/chrome-linux.zip.
this is my project:
project directory
// this is index.js
const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({ headless: true, executablePath: './chrome-linux/chrome', args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.goto('https://www.baidu.com/');
// Set screen size
await page.setViewport({ width: 1080, height: 1024 });
await browser.close();
})();
I excute node index.js, then the error came out.
(node:32513) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
./chrome-linux/chrome: symbol lookup error: ./chrome-linux/chrome: undefined symbol: gbm_bo_get_modifier
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/opt/xxx/example/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:299:20)
at Interface.<anonymous> (/opt/xxx/example/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:287:24)
at Interface.emit (events.js:412:35)
at Interface.close (readline.js:530:8)
at Socket.onend (readline.js:254:10)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1333:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:32513) 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:32513) [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.
I could not launch Chrome. How can I fix this error? Thanks.
Puppeteer version
19.7.0
Node version
14.21.1
Package manager
npm
Package manager version
6.14.17
Operating system
Linux
I'm using windows nanoserver container to launch puppeteer but it fails and I'm not sure what's wrong with my code
here's my docker file
FROM mcr.microsoft.com/windows/nanoserver:1903
COPY nodejs /windows/system32
CMD [ "node.exe" ]
COPY package.json ./
RUN npm install
# Bundle app source
COPY . .
ENTRYPOINT [ "node", "./server.js" ]
nodejs is a the node folder on my machine
and here's my package.json
{
"dependencies": {
"puppeteer": "^5.5.0",
"#axe-core/puppeteer": "^4.1.0"
}
}
and here's my server.js
const { AxePuppeteer } = require('#axe-core/puppeteer');
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: true,
ignoreDefaultArgs: ['--disable-extensions'],
args: ['--disable-dev-shm-usage', '--no-sandbox', '--disable-gpu', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.goto('https://stackoverflow.com/');
const results = await new AxePuppeteer(page).analyze();
console.log(results);
await page.close();
await browser.close();
})();
So if I build the docker image then run
docker build -t chromeHeadless
docker run chromeHeadless
I get this error
(node:1228) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (C:\app\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:193:20) at Interface.<anonymous> (C:\app\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:183:68)
at Interface.emit (events.js:326:22)
at Interface.close (readline.js:424:8)
at Socket.onend (readline.js:202:10)
at Socket.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1244:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1228) 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:1228) [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.
This is the index.js script of the bot:
const { Client, RichEmbed } = require('discord.js')
const bot = new Client()
const util = require('minecraft-server-util')
const token = 'bot_token'
const PREFIX = 'l.'
bot.on('ready', () => {
console.log('Bot has come online.')
})
bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(' ')
switch (args[0]) {
case 'status':
util.status('IP', (PORT), (error, reponse) => {
if (error) throw error
const Embed = new RichEmbed()
.setTitle('Server Status')
.addField('Server IP', reponse.host)
.addField('Server Version', reponse.version)
.addField('Online Players', reponse.onlinePlayers)
.addField('Max Players', reponse.maxPlayers)
message.channel.send(Embed)
})
break
}
})
bot.login(token)
When I type node . in the console and I type l.status on the Discord server, it shows this error on the console:
(node:3300) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Expected 'options' to
be an object or undefined, got number
at C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:46:25
at Generator.next (<anonymous>)
at C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:4:12)
at status (C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:40:12)
at Object.<anonymous> (C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:113:17)
at Generator.next (<anonymous>)
at C:\Users\HNRK\Desktop\LightSide\node_modules\minecraft-server-util\dist\status.js:8:71
at new Promise (<anonymous>)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3300) 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: 2)
(node:3300) [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.
Can anybody help? I also tried a lot of different solutions, but none of them worked.
You are using an outdatet version of discord.js. Type npm i discord.js#latest into your terminal. In the latest version of discord.js, RichEmbed() has been removed and replaced by MessageEmbed().
This is an answer based on assumption since I've never used minecraft-server-util before. Also assuming that you're using the latest minecraft-server-util,
Based on the error;
Expected 'options' to be an object or undefined, got number
And, based on this commit, You should pass the 2nd argument as an object instead of PORT since it's a type of StatusOptions instead of a number.
So, instead of;
util.status('IP', (PORT), (error, reponse) => {
You should be doing;
util.status('IP', {
port: (PORT)
}, (error, reponse) => {
I'm trying to have a spreadsheet interact with node js and I'm having connectivity issues. I don't quite know where I'm going wrong and I can't seem to find a remedy to my situation. My code is below and it is a mix of Twilio and what I've found here:
const GoogleSpreadsheet = require('google-spreadsheet');
const creds = require('./credentials.json');
// spreadsheet key is the long id in the sheets URL
async function accessSpreadsheet() {
const doc = new GoogleSpreadsheet('XXX');
await doc.useServiceAccountAuth({
client_email: creds.client_email,
private_key: creds.private_key,
});
await doc.loadInfo(); // loads document properties and worksheets
console.log(doc.title);
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
console.log(sheet.title);
console.log(sheet.rowCount);
}
accessSpreadsheet();
I'm new to JavaScript so I don't really know how to properly handle these errors. My error messages are below:
(node:15432) UnhandledPromiseRejectionWarning: TypeError: doc.loadInfo is not a function
at accessSpreadsheet (/home/spreadsheet.js:13:13)
(node:15432) 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(). (rejection id: 1)
(node:15432) [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.
/home/index.js:77
cb()
^
TypeError: cb is not a function
at /home/google-spreadsheet/index.js:77:7
at /home/node_modules/google-auth-library/lib/auth/jwtclient.js:119:5
at /home/node_modules/google-auth-library/lib/auth/jwtclient.js:138:16
at Request._callback (/home/node_modules/gtoken/lib/index.js:228:14)
at Request.self.callback (/home/node_modules/request/request.js:185:22)
at Request.emit (events.js:203:13)
at Request.<anonymous> (/home/node_modules/request/request.js:1154:10)
at Request.emit (events.js:203:13)
at IncomingMessage.<anonymous> (/home/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:291:20)
i'm using nodejs to connect to mongodb and i get this error
i added the IP and nothing happend
(node:7412) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 5 to cluster0-shard-00-02-xobf0.mongodb.net:27017 closed
at TLSSocket.<anonymous> (C:\Users\user\Desktop\NodeJS - The Complete Guide\node_modules\mongodb-core\lib\connection\connection.js:352:9)
at Object.onceWrapper (events.js:277:13)
at TLSSocket.emit (events.js:189:13)
at _handle.close (net.js:597:12)
at TCP.done (_tls_wrap.js:388:7)
(node:7412) 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(). (rejection id: 1)
(node:7412) [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.
[nodemon] clean exit - waiting for changes before restart
Try this ,
const MongoClient = require("mongodb").MongoClient;
const uri ="mongodb+srv://user:userpassword#meanapp-srlw9.mongodb.net/test?retryWrites=true";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices");
// perform actions on the collection object
console.log("connencted");
client.close();
});
For now, change your cluster setting to connect from anywhere