nx-console: Generate navigation menu fails to list available commands in version 10.0.0

Angular console version 10.0.0 disabled the Generate menu item and does not display the command palette for my project. When I downgrade to version 9.1.1, the command works by displaying the list of commands.

I have the angular.json and nx.json files in my workspace. I do not have the new workspace.json file.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 22 (1 by maintainers)

Most upvoted comments

The issue seems to still be present even in the latest version. I’ve since written a little script that fixes the issue. It sucks that this is necessary at all, but it is what it is. The script simply reads in the package.json of the offending packages and removes the erroneous entries.

const fs = require('fs');
const path = require('path');

function readFile(file) {
  return new Promise((resolve, reject) => {
    fs.readFile(file, {}, (err, content) => {
      if (err) {
        reject(err);
      } else {
        resolve(content);
      }
    });
  });
}

function writeFile(file, content) {
  return new Promise((resolve, reject) => {
    fs.writeFile(file, content, (err) => {
      if (err) {
        reject(err);
      } else {
        resolve();
      }
    });
  });
}

(async function () {
  console.log('Fixing Telerik/Progress packages erroneous schematics entries');

  const knownBadPackages = ['kendo-angular-l10n', 'kendo-angular-intl', 'kendo-angular-common'];
  const knownBackPackagesJsonFiles = knownBadPackages.map((bp) => path.join(__dirname, '..', `node_modules/@progress/${bp}/package.json`));
  const knownBadPackaesContentPromises = knownBackPackagesJsonFiles.map((bp) => readFile(bp).then((res) => ({ packagePath: bp, result: JSON.parse(res) })));
  /** @type Array<{ packagePath: string, result: string }>*/
  const badPackagesFileContent = await Promise.all(knownBadPackaesContentPromises);

  for ({ packagePath, result } of badPackagesFileContent) {
    delete result.schematics;
    await writeFile(packagePath, JSON.stringify(result, null, 3));
  }

  console.log('Successfully fixed Telerik/Progress packages');
})();

The const knownBadPackages array includes the packages I know of and use that need fixing. If you find more, simply add to the list. To use the script, simply make a folder called scripts at the same level you have your package.json and node_modules and save the script as fixProgressPackages.js in the newly created scripts folder

Then in your package.json add, under scripts:

"telerik-fix-postinstall": "node ./scripts/fixProgressPackages.js",

Then, in your package.json, find the “postinstall” script and add

&& npm run telerik-fix-postinstall

After that simply run npm install and the fix should be applied. Since it’s in your postinstall this fix will also be applied for all your coworkers and on fresh installs as well.

Verified #971 does handle this issue and reports the error along with Invalid package.json for schematic ${collectionName} in the dev tools console. Invalid schematics are not listed in the dropdown.

@SirajB The error sadly doesn’t point to a specific folder. I just found those packages by trial and error by individually uninstalling things from my package.json. There’s a chance that some other packages you’re using are exhibiting the same problem as the telerik packages. You might want to narrow it down to those packages and then adapt my script.

Any solution?

You are on to something @Jejuni. My project also imports @progress dependencies when I reported this issue.

Indeed, when I opened another Nx worksapce without @progress dependencies using Nx Console version 10.0.0, I was able to see the Generate command palette.

same scenario here, i even report the issue to telerik and they refer to this issue. until the issue is solved i am using v9.1.1

It’s true that the tool shouldn’t be crashing because of a null/undefined issue and handle it more gracefully. But it’s also true that the Telerik package.json references non-existing folders. You’d hope that Telerik would also be on the issue and try to fix it…

same scenario here, i even report the issue to telerik and they refer to this issue. until the issue is solved i am using v9.1.1

I’ve got the same error : [[object Object]]Cannot convert undefined or null to object

Cannot convert undefined or null to object at Function.entries (<anonymous>) at readCollectionSchematics (c:\Users\Jejun\.vscode\extensions\nrwl.angular-console-10.0.0\main.js:167374:12) at readCollection(...)

I’ve narrowed it down to the suite of Telerik products we have installed. After further inspection some packages in the node_modules/@progress folder cause the issues. Among them was, for instance, kendo-angular-l10n.

This package, unlike most others, did not have a schematics folder. However, in the included package.json there were 2 entries referencing the schematics: (...) "schematics": "./schematics/collection.json", "files": [ "dist", "schematics" ] (...)

Removing these entries fixed the problem. However, after reinstalling or updating the package.json will be regenerated and the problem starts appearing again. Could this be fixed so a non-existing schematics entry/folder doesn’t cause the crash?

I have the same problem.

stack trace: TypeError: Cannot convert undefined or null to object at Function.entries (<anonymous>) at readCollectionSchematics (c:\foldername\nrwl.angular-console-10.0.0\main.js:167374:12) at readCollection (c:\foldername\nrwl.angular-console-10.0.0\main.js:167363:16)