Node.js: Create a CLI tool in Javascript
tutorial needs package import method update
#976
Open
1 task done
Main programming language
JavaScript
Node.js: Create a CLI tool in Javascript
Tutorial URL
Page of the problem
On page 7 of the tutorial we see
chalk
package has been installed to make your CLI texts colorfulThis is the code given in tutorial:
However The chalk module from version 5.0.0 and onwards is an ECMAScript module (ESM), and it no longer supports CommonJS require(). This is why you're going to see an error when you try to require it.
Solution: To use chalk, you need to use dynamic import() instead of require(). Here's how you can do it:
New code for the page 7 of the tutorial:
Similar Problem for The Package-Up Method:
Page 8 : https://citw.dev/tutorial/create-your-own-cli-tool?p=8
It should also be dynamically imported like this:
Category
The text was updated successfully, but these errors were encountered: