As I work on my Angular CLI 6 application, I've been exploring ways to add some styling to my console logs using the Chalk package.
To test things out, I imported Chalk into my app.component.TS file like so:
import { component } from '@angular/core';
import * as chalk_ from 'chalk';
@Component({
//not important
})
export class AppComponent {
title = 'My App';
constructor() {
console.log(chalk.blue('Hello'));
}
Interestingly, when I tried using chalk.blue, it threw an error saying "Property blue does not exist." However, changing it to chalk.default.blue resolved the issue and VS code showed no errors.
But, upon checking the browser console, I encountered this error: index.js:8 Uncaught ReferenceError: process is not defined.
I'm a bit stumped by this. It seems like other packages like Colors also require you to use require() for implementation, which feels outdated since it's in ES5 style...
const chalk = require('chalk');
or
var colors = require('colors/safe');