Baileys | error while compiling example.ts file - node.js

I cloned this repository: https://github.com/adiwajshing/Baileys.
When I compile the example.ts file via the yarn example command, which is located in the ./Example/example.ts folder, the following error occurs:
PS D:\Programming\Web\Baileys> yarn example
yarn run v1.22.19
$ node --inspect -r ts-node/register Example/example.ts
Debugger listening on ws://127.0.0.1:9229/c6e4eec7-1dea-4762-8fa6-a10bcd74aa7a
For help, see: https://nodejs.org/en/docs/inspector
using WA v2.2243.7, isLatest: true
D:\Programming\Web\Baileys\src\Socket\socket.js:57
var ws = new ws_1["default"](waWebSocketUrl, undefined, {
^
TypeError: ws_1.default is not a constructor
at makeSocket (D:\Programming\Web\Baileys\src\Socket\socket.js:57:14)
at makeChatsSocket (D:\Programming\Web\Baileys\src\Socket\chats.js:63:40)
at makeGroupsSocket (D:\Programming\Web\Baileys\src\Socket\groups.js:57:44)
at makeMessagesSocket (D:\Programming\Web\Baileys\src\Socket\messages-send.js:61:46)
at makeMessagesRecvSocket (D:\Programming\Web\Baileys\src\Socket\messages-recv.js:62:55)
at makeBusinessSocket (D:\Programming\Web\Baileys\src\Socket\business.js:56:59)
at makeWASocket (D:\Programming\Web\Baileys\src\Socket\index.js:17:82)
at startSock (D:\Programming\Web\Baileys\Example\example.ts:31:27)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
what is it connected with?
node
v18.7.0
tsc
Version 4.9.4
yarn
1.12.19
I tried to solve the problem by changing the imports as mentioned here https://github.com/node-cache/node-cache/issues/59, but it didn't help.

Related

How disabled esLint "error Parsing error: Missing semicolon." for Heroku Procfile?

I'm trying to commit a Procfile worker for a Twitter bot to Heroku, which is located at "src/Procfile" with two other files "src/bot.ts" and "src/config.ts"
worker: node bot.ts
When commited esLint error:
$ eslint --ext .js,.json,.ts --fix /Users/user-file/Codes/folder/twitter-bot/node-ts-starter/src/Procfile
/Users/user-file/Codes/folder/twitter-bot/node-ts-starter/src/Procfile
2:13 error Parsing error: Missing semicolon.
1 | // eslint-disable-next-line #typescript-eslint/semi
> 2 | worker: node bot.ts
| ^
3 |
✖ 1 problem (1 error, 0 warnings)
I tried commenting it out with:
// eslint-disable-next-line #typescript-eslint/semi
worker: node bot.ts
It didn't work.
last I tried putting the "Procfile" outside of the "src folder"
and edit the "Procfile" to:
worker: node src/bot.ts
it went thru but, it wasn't detected as a worker but a web page instead.
Appreciate the help, thanks in advance!

node.js & react - server not up, from github project

I found one project on GitHub darkwire and wanted to install it and play with it. Firstly I tried to install it from windows. I installed Node.js and Yarn and I got errors with the command: yarn dev
`C:\darkwire.io-master>yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
[0] 'c' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'client' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] c exited with code 1
[1] client exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`
My next step was to try it in ubuntu 19.10, firstly I installed again Node.js and Yarn and again used: yarn dev. I got an error but now was open site and it not working, just say "Disconnected"
```qq#ubuntu:~/Downloads/darkwire.io-master$ yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
$ nodemon src/index.js --exec babel-node
$ react-scripts start
[1] [nodemon] 1.19.0
[1] [nodemon] to restart at any time, enter `rs`
[1] [nodemon] watching: *.*
[1] [nodemon] starting `babel-node src/index.js`
[1] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[1] Checking for inactive rooms...
[1] Darkwire is online at port 3001
[1] events.js:183
[1] throw er; // Unhandled 'error' event
[1] ^
[1]
[1] Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
[1] at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
[1] [nodemon] app crashed - waiting for file changes before starting...
[0] Starting the development server...
[0]
[0] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[0] Compiled successfully!
[0]
[0] You can now view darkwire-client in the browser.
[0]
[0] Local: http://localhost:3000/
[0] On Your Network: http://175.124.13.111:3000/
[0]
[0] Note that the development build is not optimized.
[0] To create a production build, use yarn build.
[0]
```
screenshot
I think maybe I have the wrong version Node.js and try install 9.x version, download again project and try again, it not help, try change port from 3001 to 3000, not help.
From their README.md
Darkwire Server
Darkwire server is a Node.js application that requires redis.
So please install a compatible redis server. Redis tutorial

How can I use saucelabs connect with circle-ci 2.0?

In circle-ci 1.0 the config file seemed to specify dependencies. I noticed that in circle-ci 2.0 that this concept is gone to some degree.
Sooo I tried the following:
steps:
- checkout
- run:
name: Install Sauce Connect
command: |
wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
tar -xzf sc-latest-linux.tar.gz
...
- run: yarn integration
Seems like this didn't quite pan out. I get the following result in circle-ci's console:
#!/bin/bash -eo pipefail
yarn run integration
yarn run v0.24.6
$ node_modules/.bin/wdio test/wdio.conf.js
A service failed in the 'onPrepare' hook
Error: Could not start Sauce Connect. Exit code 1 signal: null
at ChildProcess.<anonymous> (/home/circleci/repo/node_modules/sauce-connect-launcher/lib/sauce-connect-launcher.js:559:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
Continue...
ERROR: connect ECONNREFUSED 127.0.0.1:4445
chrome
Error
ERROR: connect ECONNREFUSED 127.0.0.1:4445
chrome
Error
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1
I'm using wdio, with the sauce and mocha plugins. It works locally. Ideas? Any guides that exist anywhere for this? Google didn't produce any answers for circle-ci 2.0 and saucelabs integrations.

Grunt error when running Sails.js app in Amazon ElasticBeanstalk

I am moving a Sails.js app hosted on Heroku to Amazon ElasticBeanstalk. When the application launches, it throws the following Grunt error (pulled from eb logs):
info: Sails <| .-..-.
info: v0.11.5 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/var/app/current`
info: To see your app, visit http://localhost:8081
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Mon Feb 29 2016 08:21:46 GMT+0000 (UTC)
debug: Environment : development
debug: Port : 8081
debug: --------------------------------------------------------
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
>> FileError: '../bower_components/bootstrap/less/grid.less' wasn't found in assets/styles/importer.less on line 9, column 1:
>> 8 // Import Bootstrap
>> 9 #import "../bower_components/bootstrap/less/grid.less";
>> 10 #import "../bower_components/bootstrap/less/mixins.less";
Warning: Error compiling assets/styles/importer.less
Aborted due to warnings.
Running "less:dev" (less) task
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/var/app/current/.tmp` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 497 /var/app/current/.tmp
The same code runs fine on my local development laptop and on Heroku but not on ElasticBeanstalk. Why is it unable to find the bootstrap files? This being a PaaS, I can't even run the recommended sudo chown command that the log recommended. Also to be clear, I have the following command in my package.json file:
"scripts": {
"postinstall": "bower install; grunt build",
"debug": "node debug app.js",
"start": "node app.js"
}
I have instructed the script to run bower install after the NPM packages are installed in the machine. None of the images in my /assets folder seem to load either. Not sure what's going on. Please help.

What is the issue "node" is working but "nodemon" is not woking on windows 7 64-bit in node.js?

I am new to node.js. node is working fine but when I installed the nodemon package, it gives an error: exception in nodemon killing node, even when installed globally.
22 Jun 13:07:29 - [nodemon] v1.3.7
22 Jun 13:07:29 - [nodemon] to restart at any time, enter `rs`
22 Jun 13:07:29 - [nodemon] watching: *.*
22 Jun 13:07:29 - [nodemon] starting `node server.js`
exception in nodemon killing node
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
----------------------------------------------------------
If appropriate, please file an error with the output from:
$ node
C:\Users\username\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.
js server.js --dump
At http://github.com/remy/nodemon/issues/new
Possible solutions.
1. Permissions
The problem may be in your file permissions. Execute in git bash or from windows to give full permission to the project folder.
$ chmod -R 777 [folder]
2. Environment Variables
Missing "C:\Windows\System32" in the PATH.
Github issue
3. Reinstall
Altogether remove nodemon using npm and try reinstalling.
npm uninstall -g nodemon
4. Update nodejs
If you have an old version of NodeJS, try updating it. I prefer entirely removing NodeJS and reinstalling it again.
Step by steps to remove NodeJS in windows
Note: Your question may not be rich enough to answer correctly. Please include more information about questions if those didn't work.
Help spawn to locate your nodemon.cmd like this:
var nodemonCmd = (process.platform == 'win32') ? 'node_modules\\.bin\\nodemon.cmd' : 'nodemon'
myApp = spawn(nodemonCmd, ['build/server.bundle']);
Hope it works :)

Resources