Skip to content

Commit

Permalink
Upgrade node version (#2129)
Browse files Browse the repository at this point in the history
* Upgade node version

* Update package.json

* Node v18

* Update README.md

* Prevent unverified lib upgrade

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 3, 2024
1 parent 72a1881 commit 79f0563
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,36 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke

The module is now available on npm! `npm i whatsapp-web.js`

Please note that Node v12+ is required.
Please note that Node v18+ is required.

## QUICK STEPS TO UPGRADE NODE

### Windows

#### Manual
Just get the latest LTS from https://nodejs.org

#### npm
```powershell
sudo npm install -g n
sudo n stable
```

#### Choco
```powershell
choco install nodejs-lts
```

#### Winget
```powershell
winget install OpenJS.NodeJS.LTS
```

### Ubuntu / Debian
```bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
```

## Example usage

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "2.1.2",
"mime": "^3.0.0",
"node-fetch": "^2.6.5",
"node-webpmux": "3.1.0",
"puppeteer": "^13.0.0"
"node-fetch": "^2.6.9",
"node-webpmux": "3.1.7",
"puppeteer": "^18.2.1"
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
Expand All @@ -49,7 +49,7 @@
"sinon": "^13.0.1"
},
"engines": {
"node": ">=12.0.0"
"node": ">=18.0.0"
},
"optionalDependencies": {
"archiver": "^5.3.1",
Expand Down

10 comments on commit 79f0563

@Davep2020
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble running tests on the platform; it says it's damaged. Should I perform any additional process?

@marcelolohamann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34
const version = indexHtml.match(/manifest-([\d\.]+).json/)[1];
^

TypeError: Cannot read properties of null (reading '1')

@lc961012
Copy link

@lc961012 lc961012 commented on 79f0563 Apr 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34
const version = indexHtml.match(/manifest-([\d.]+).json/)[1];
^

After making this change in LocalWebCache.js for this error,

// async persist(indexHtml) {
// // extract version from index (e.g. manifest-2.2206.9.json -> 2.2206.9)
// const version = indexHtml.match(/manifest-([\d\.]+).json/)[1];
// if(!version) return;

//     const filePath = path.join(this.path, `${version}.html`);
//     fs.mkdirSync(this.path, { recursive: true });
//     fs.writeFileSync(filePath, indexHtml);
// }
async persist(indexHtml) {
    const matchResult = indexHtml.match(/manifest-([\d\\.]+)\.json/);
    if (!matchResult) return;

    const version = matchResult[1];
    const filePath = path.join(this.path, `${version}.html`);
    fs.mkdirSync(this.path, { recursive: true });
    fs.writeFileSync(filePath, indexHtml);
}

I can generate QR codes now, but after successful login, the following error occurs:

F:\code\pro-admin-billion\billion-platform\nodejsServe\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
at puppeteer_evaluation_script:5:95
at ExecutionContext._evaluateInternal (F:\code\pro-admin-billion\billion-platform\nodejsServe\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (F:\code\pro-admin-billion\billion-platform\nodejsServe\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
at async Client.initialize (F:\code\pro-admin-billion\billion-platform\nodejsServe\node_modules\whatsapp-web.js\src\Client.js:323:9)

Node.js v20.11.1

When I try to use other lower versions, I find that after successful login, other listening events cannot be monitored. What could be the reason for this?

@snfajar
Copy link

@snfajar snfajar commented on 79f0563 Apr 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

@marcelolohamann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

SOLUÇÂO:
Olá a todos! Para instalar o patch, execute:

npm install github:pedroslopez/whatsapp-web.js#webpack-exodus

A razão pela qual ainda não foi fundida é porque ainda estou trabalhando na estabilidade.

@marcelolohamann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link da solução oficial #2789

@snfajar
Copy link

@snfajar snfajar commented on 79f0563 Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

SOLUÇÂO: Olá a todos! Para instalar o patch, execute:

npm install github:pedroslopez/whatsapp-web.js#webpack-exodus

A razão pela qual ainda não foi fundida é porque ainda estou trabalhando na estabilidade.

still can not

@washingtonrbo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I downgraded node to version 14.21.3, applied the fix npm install github:pedroslopez/whatsapp-web.js#webpack-exodus and updated the libs. Now my project is back up and running!

@faisalfjri
Copy link

@faisalfjri faisalfjri commented on 79f0563 Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a problem after updating the package, it doesn't work well on alpine, I use docker node:lts-alpine.

after I changed to node:18-slim , it worked fine.

this is my Dockerfile:

FROM node:18-slim

# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
  wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
  sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
  apt-get update && \
  apt-get install google-chrome-stable -y --no-install-recommends && \
  rm -rf /var/lib/apt/lists/*
RUN apt-get update  && apt-get install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3005

CMD ["node", "app.js"]

@snfajar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I downgraded node to version 14.21.3, applied the fix npm install github:pedroslopez/whatsapp-web.js#webpack-exodus and updated the libs. Now my project is back up and running!

Thanks work gan

Please sign in to comment.