Angular CLI version 13 does not support the execution of "ng" commands

Recently, I upgraded the Angular CLI to version v13 globally. However, upon attempting to use the ng command, I encountered a puzzling error message:

https://i.sstatic.net/gAgB4.png

After consulting advice provided here, I learned that Angular v13 is supposed to work with Node version v16.10.x. So, I promptly installed Node version v16.10.0, only to find that the issue persisted.

Following conventional troubleshooting steps, I tried uninstalling and reinstalling Angular CLI as follows:

npm uninstall -g @angular/cli
npm install -g @angular/cli@latest

I even attempted clearing the npm cache, but to no avail.

Curiously, reverting back to Angular CLI v12 resolved the problem completely.

Is this a well-known issue specific to Angular CLI version v13?

Environment:

Windows 10 (win32 x64)

Update:

In response to various suggestions, I switched from using Windows Scripting Host to utilizing Node.js for execution of .js files. While this adjustment allowed the ng command to function, it unexpectedly resulted in every entered command defaulting to displaying the ng help output. It seems as though all commands are being erroneously mapped to the ng help command.

Answer №1

Here is a possible solution that may resolve your issue:

  1. Delete the user environment variable: C:\Users\AppData\Roaming\npm\node_modules@angular\cli\bin

  2. Remove angular from your system

  3. Uninstall nodejs completely

  4. Restart your computer

  5. Reinstall both nodejs and angular

Answer №2

By default, on Windows systems, '.js' files are associated with Windows Scripting Host instead of Node.js. This means that the script will not run as expected with Node. If you navigate to a '.js' file in explorer, you'll notice that it's not recognized as JavaScript.

To solve this issue, you can update the properties of a JavaScript file and set Node.js executable file as the program to open these types of files.

Answer №3

  1. To delete your version, use this command

npm uninstall -g @angular/cli

  1. Use the following command to uninstall the node file

npm uninstall

  1. Navigate to your computer's file explorer Access drive C. In the "search This PC" bar, look for "App Data" and then "Roaming" Delete your "npm" file in the "Roaming" folder
  2. Run the "npm install" command once more
  3. Now execute the command "npm install -g @ angular / cli"

Answer №4

While I cannot guarantee that this solution will definitively solve your issue, I have an alternative suggestion that may offer a different approach. This method proved helpful for me when managing multiple projects with conflicting node versions on my system: CONSIDER USING A NODE MANAGER

I recommend trying out Volta, a convenient tool for managing your JavaScript command-line applications.

You can easily download the installer from the following link: https://github.com/volta-cli/volta/releases/download/v1.0.5/volta-1.0.5-windows-x86_64.msi Once downloaded, execute the installer (ensure you have administrator privileges) to set it up.

After installation, simply run: volta install node@16 (or specify a different Node version if needed) This command will install the specified version of node using Volta's unique method:

Unlike other tools, Volta does not rely on complex OS features or shell-specific hooks. Instead, it leverages shims to seamlessly route commands to the correct tool version with the appropriate Node engine in use. Installing tools through Volta adds intelligent shims to your PATH, ensuring fast and efficient execution without external dependencies.

Answer №5

If you're having trouble running Angular properly in the command line, consider changing your default .JS files opener to Node.js, which can be found at "C:\Program Files\nodejs". This simple fix should resolve the issue.

  1. To do this, simply right-click on any .js file and select properties
  2. Next, update the "opens with" setting to point to Node located here: ""C:\Program Files\nodejs\node"
  3. After making these changes, your Angular commands should execute correctly in the cmd

Answer №6

Experimenting with different versions of node.js and angular can disrupt the npm directories, causing the ng command to fail.

Windows' built-in program removal/uninstallation process for Node does not delete the npm folder

C:\Users\\{user}\AppData\Roaming\npm.

To uninstall Node completely, manually delete this folder.

When downloading a Node installer for Windows, it also installs a compatible version of npm. Therefore, these folders need to be removed before reinstalling Node - I had to do this manually to get ng working again.

Answer №7

In order to resolve the issue, it is recommended to update the encoding format of the ng.js file from bom + utf8 to utf8

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am receiving null values for my environment variables

Seeking assistance with my angular 12 + node 14 project. Despite researching extensively, I keep encountering an undefined error when trying to utilize environment variables. I have placed a .env file in the same folder as my login.component.ts since my r ...

Testing Angular Service Calls API in constructor using Jasmine Test

My service is designed as a singleton, and its constructor initiates an API call function. This simplifies the process during service initialization, reducing the complexity and dependencies on various components like AppComponent to import and execute API ...

Having trouble adding Bootstrap to Angular with Webpack? You might come across the error message: "File to import not found or unreadable: ../bootstrap/sc

I have decided to incorporate Bootstrap into my project. My attempt at installation involved using "bootstrap": "^4.0.0-alpha.5" I followed a tutorial found at https://github.com/AngularClass/angular2-webpack-starter/wiki/How-to-use-Bootstrap-4-and-Sass- ...

Step-by-step tutorial on how to enable app logout functionality using Node.js and Okta

I have created a web app using Okta with OIDC and Node Express for user authentication. I want users to be able to log out of my app without logging out of the company Okta, which is used for multiple websites. Okta recommends this approach on their websit ...

Sorting through a list of strings by checking for a specific character within each string

After spending years dabbling in VBA, I am now delving into Typescript. I currently have an array of binary strings Each string represents a binary number My goal is to filter the array and extract all strings that contain '1' at position X I ...

Astro encounters issues with importing MD files when built, but functions properly when running npm dev

Currently, I am facing an issue with importing MD files in Astro and I am using the following code snippet: import * as a from '../content/a.md'; While this code works perfectly fine when running "npm run dev", it throws an error during the buil ...

Encountering an error message that reads "State.Push is not a valid function" upon integrating

Currently, I am working on developing a Todo app using react-typescript and redux. During testing, I noticed that the app functions properly without redux-persist, displaying the list of added tasks. However, upon integrating redux-persist, the store does ...

Versatile Typescript options

Is it possible to enforce a value to be within a list using TypeScript with enums? Can this be achieved with TypeScript type definitions? enum Friend { JOHN, SALLY, PAUL, } type MyFriends = { friends: Friend[], bestFriend: <> //How ca ...

How can you retrieve the keys of an object that conforms to an interface?

In the following demonstration, we have two objects - KEYS and KEYS2. When importing KEYS in index.ts, autocomplete suggestions are available for K1 and K2 because KEYS does not adhere to an interface. On the other hand, with KEYS2, autocomplete is not pr ...

Prevent coverage tracking for files or paths enclosed in square brackets in jest

I am trying to exclude a specific file from test coverage in Jest by modifying the collectCoverageFrom array. The file name contains square brackets, and I have added an entry with a negation for this file. collectCoverageFrom: [ './src/**/*.{js ...

Exploring the Vue 3 Composition API with TypeScript and Working with Object Keys

Exploring the Vue-3 composition API and seeking guidance on utilizing types with TypeScript in Vue. Looking for more detailed information on how to define object properties and specify keys in TypeScript within the composition API, as the current document ...

Exploring the Possibilities of Nipplejs Integration in Vue with Quasar

Trying to implement Nipplejs in my Vue Project using quasar Components. Installed nipplejs through npm install nipplejs --save. Attempted integration of the nipple with the code snippet below: <template> <div id="joystick_zone">&l ...

Bringing together a collection of objects connected by shared array elements

Given the types defined as: type A = { commonKey: { a: string }[] }; type B = { commonKey: { b: number }[] }; Is it possible to create the type below without explicitly specifying commonKey? type C = { commonKey: { a: string, b: number }[] } My initial a ...

How to format dates when exporting Excel from Kendo Grid in Angular 2

When attempting to export data from the Kendo UI Grid for Angular, there seems to be an issue with formatting the date column. The actual date value is not being displayed correctly in the exported file. Below is a snippet of the code: <kendo-excelexpo ...

Does node js version 17.4.0 provide the stability needed to create a long-lasting Docker image?

When creating a docker image for my Angular app, I find myself unsure about which latest version of Node.js to use. I want one that is stable and offers long-term support. Thoughts on using v17.4.0? FROM node:12.16.1 ENV ARG "" RUN mkdir -p /us ...

I was unable to showcase various maps

import TileLayer from 'ol/layer/Tile'; import OSM from 'ol/source/OSM'; layers: any; base_maps:any; map = new Map({ target: 'map', layers: [ new TileLayer({ source: new OSM({ maxZoom: 23, }), ...

The JsonFormatter is throwing an error because it is trying to access the property 'on' of an undefined variable

I have encountered an error while attempting to generate an HTML report using cucumber-html-reporter The error message is: Unhandled rejection TypeError: Cannot read property 'on' of undefined at new JsonFormatter (C:\path-to-project\ ...

MediaRecorder is not compatible with Protractor unit tests in Angular

Currently working on an Angular 11 project that includes unit tests. Just introduced a MediaRecorder into the project, but now none of the tests are functioning properly. The test compilation is throwing this exception: error TS2304: Cannot find name &apos ...

Looking to build a library with Angular 5?

Is it possible to develop a library in Angular 5? Will this library be guaranteed to maintain compatibility with upcoming versions of Angular? ...

Efficiently linking styles through computation in Angular

So I've been working with Angular5 and I figured out how to bind an HTML element's style to a Boolean value. However, I'm struggling to find a way to do this for multiple styles simultaneously. For example, I have this code snippet that wor ...