hello, I am trying to install Twitch on my linux os but i encounter this error.
"ken@kenny:~/Development/projects/MessageManager$ twitch login
/home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/lib/twitch.js:9
chalk = require(‘chalk’),
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/node_modules/chalk/source/index.js from /home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/lib/twitch.js not supported.
Instead change the require of index.js in /home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/lib/twitch.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/lib/twitch.js:9:26) {
code: ‘ERR_REQUIRE_ESM’
}
Node.js v20.11.0"
i have tried to modify the file using imports but error stills persists
Looks like you’ve tried to install twitch-cli - npm which hasn’t been touched in nine years.
So you’ve installed the wrong thing.
For linux for the official CLI you would need to manually download the latest release from GitHub
If infact you are after the node twitch-cli you would need to reach out to the developer of that project, not this forum, given what you have installed is for watching streams outside of the Twitch website…
I think to resolve this, you’ll need to modify the ‘twitch.js’ file in the specified directory (/home/ken/.nvm/versions/node/v20.11.0/lib/node_modules/twitch-cli/lib/) to use dynamic import() instead of require(). Look for the line that requires ‘chalk’ and replace it with a dynamic import statement. This should resolve the ERR_REQUIRE_ESM error and allow Twitch CLI to function properly on your Linux OS.