Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in ./node_modules/discord-rpc/src/client.js 8:4-21 #163

Closed
AlphaBeta906 opened this issue Feb 13, 2022 · 1 comment
Closed

ERROR in ./node_modules/discord-rpc/src/client.js 8:4-21 #163

AlphaBeta906 opened this issue Feb 13, 2022 · 1 comment

Comments

@AlphaBeta906
Copy link

AlphaBeta906 commented Feb 13, 2022

Hi,

I am using a React project using this RPC. I have seem to find an error here:

ERROR in ./node_modules/discord-rpc/src/client.js 8:4-21
Module not found: Error: Can't resolve 'timers' in '/Users/alphabeta906/Documents/BloodAlchemy/my-app/node_modules/discord-rpc/src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

This is my webpack config:

module.exports = {
    target: 'node',
    entry: require.resolve('./src/index.js'),
    resolve: {
        fallback: { "timers": require.resolve("timers-browserify") }
    },
};

Here is my code:

import { Client } from 'discord-rpc';

const client = new Client({
  transport: 'websocket'
});

const setActivity = (data) => {
  if (discord === true) {
   client.setActivity(data);
  }
}

const startTimestamp = new Date();

client.on('ready', () => {
  setActivity({
    details: user !== '' ? `Logged in as ${user}` : 'Logged in as Guest',
    state: 'Doing Alchemy',
    startTimestamp,
    largeImageKey: 'logo',
    largeImageText: 'Blood Alchemy RIP 2021-2022',
    instance: false,
  })
});

client.login('the client id');

It seems to work on node and on terminal, so it's a web only problem. I have also installed timers-browsify.

Thanks!

@AlphaBeta906
Copy link
Author

Apparently the issue was resolved due to the webpack config not updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant