I am implementing a Yeoman generator, it works but when I run it I am getting a lot of undesired warnings as shown in this image:
I created the most basics generator in Javascript, it only contains the package.json, the index.js in the generators/app folder and a folder named templates with a single HTML file inside.
In the image I use PowerShell but I have used Git Bash also to run the Yo command, I have tried in Windows 10 and 11, I tried Node 14.20.0 and 16.16.0 and the version of Yeoman is 4.3.0. I read several posts about the cause being the shelljs but that library gets installed with just the following dependencies:
{
"name": "generator-diego",
"version": "0.0.1",
"description": "First Yo generator",
"files": [
"generators"
],
"keywords": [
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "^1.0.0"
}
}
Here the code of my generator:
var Generator = require('yeoman-generator');
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);
this.option("default");
}
async prompting() {
this.answers = await this.prompt([
{
type : 'input',
name : 'appName',
message : 'Your application name: ',
when: !this.options.default
}
]);
}
writing() {
if (this.options.default) {
this.answers = { appName: 'auto-app' }; // Set a default answer, more can be added
}
this.fs.copyTpl(
this.templatePath('basic-template'),
this.destinationPath(this.answers.appName),
{
appName: this.answers.appName
}
);
}
}
Does anybody knows how to fix this issue?
These warnings appear due to the versions you are using for node and Yeoman-generator. Upgrading Yeoman-generator to the latest version should solve the problem. Also, it would be a good practice. That version is very old. I hope it helps.