Comments

Common Angular Errors

In this post, I’m going to list the most common errors you may encounter while getting started with Angular. For each error, I’m going to explain what it means and how to solve it.

This post is a work in progress and I’m planning to add more errors. If there is an error you encounter often, please let us know by dropping a comment.

Error 1: ‘ng’ is not recognized

When creating a new project with Angular CLI, you may receive the following error:

'ng' is not recognized as an internal or external command.

This error is simply telling you that Angular CLI is either not installed or not added to the PATH. To solve this error, first, make sure you’re running Node 6.9 or higher. A lot of errors can be resolved by simply upgrading your Node to the latest stable version.

Open up the Terminal on macOS/Linux or Command Prompt on Windows and run the following command to find out the version of Node you are running:

node --version

If you’re running an earlier version of Node, head over to nodejs.org and download the installer for the latest stable version.

Once you have installed Node 6.9+, you need to install Angular CLI globally:

npm install -g @angular/cli

Note the -g flag here. This tells NPM that you want to install this package globally so you can run it from any folders on your machine.

Error 2: node_modules appears empty

When you run ng serve, you may receive the following error:

node_modules appears empty, you may need to run `npm install`.

Our Angular applications use a bunch of 3rd-party libraries. These libraries are stored in the node_modules folder inside your project folder. When you create a new project using Angular CLI, these third-party libraries should be installed automatically. However, if you’re using a corrupted or a buggy version of Angular CLI, these libraries are not installed. So, you need to manually install them.

To solve this error, run npm install from the project folder. This command will look at package.json in your project folder. This file includes the list of dependencies of your project. NPM will download and store these dependencies in the node_modules folder.

 

If you found this post helpful, please share it with others.

If there is an error you’d like me to add to this post, please let me know using the comment box below.

Also, if you want to learn Angular properly from basics to the advanced topics, check out my complete Angular course.

Hi! My name is Mosh Hamedani. I’m a software engineer with two decades of experience and I’ve taught over three million people how to code or how to become professional software engineers through my YouTube channel and online courses. It’s my mission to make software engineering accessible to everyone.
Tags:

9 responses to “Common Angular Errors”

  1. waffo1991 says:

    good

  2. Sayed says:

    Hello,
    Every time I run “npm -g @angular/cli” it fails with the following error:
    npm ERR! code ECONNRESET
    npm ERR! errno ECONNRESET
    npm ERR! network request to https://registry.npmjs.org/parseuri failed, reason: read ECONNRESET
    npm ERR! network This is a problem related to network connectivity.
    npm ERR! network In most cases you are behind a proxy or have bad network settings.
    npm ERR! network
    npm ERR! network If you are behind a proxy, please make sure that the
    npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

    I do not have proxy and I can open that link on the browser and get the json

  3. Adnan Aslam says:

    Just delete the node_modules from directory and run npm install

    if you are facing any issue similar to this :
    Error: Path “/app/app.module.ts” does not exist.
    Path “/app/app.module.ts” does not exist.

  4. Steve Carmel says:

    Hello,

    hier ist what I become as Error:

    ——————–: after I installed Angular:

    C:\Users\egoue>npm install -g @angular/cli
    C:\Users\egoue\AppData\Roaming\npm\ng -> C:\Users\egoue\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

    > @angular/cli@6.0.8 postinstall C:\Users\egoue\AppData\Roaming\npm\node_modules\@angular\cli
    > node ./bin/ng-update-message.js

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32″,”arch”:”x64″})

    + @angular/cli@6.0.8
    updated 1 package in 28.9s

    ——————–: when I ask to know which version of Angular has been installedr:

    C:\Users\egoue>ng –version
    module.js:549
    throw err;
    ^

    Error: Cannot find module ‘symbol-observable’
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object. (C:\Users\egoue\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js:11:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

  5. Uma Shankar Gupta says:

    ‘ng’ is not recognized as an internal or external command, operable program or batch file.—Nothing is working for me, went accross google for more than 10 pages, no luck

  6. manish jha says:

    Microsoft Windows [Version 10.0.16299.785]
    (c) 2017 Microsoft Corporation. All rights reserved.

    C:\Users\manish jha>node -v
    v10.14.1

    C:\Users\manish jha>npm install -g @angular/cli
    npm WARN tarball tarball data for typescript@3.1.6 (sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==) seems to be corrupted. Trying one more time.
    npm ERR! path C:\Users\manish jha\AppData\Roaming\npm\node_modules\.staging\typescript-dd2c5bdd\lib\tsc.js
    npm ERR! code EPERM
    npm ERR! errno -4048
    npm ERR! syscall unlink
    npm ERR! Error: EPERM: operation not permitted, unlink ‘C:\Users\manish jha\AppData\Roaming\npm\node_modules\.staging\typescript-dd2c5bdd\lib\tsc.js’
    npm ERR! { [Error: EPERM: operation not permitted, unlink ‘C:\Users\manish jha\AppData\Roaming\npm\node_modules\.staging\typescript-dd2c5bdd\lib\tsc.js’]
    npm ERR! cause:
    npm ERR! { Error: EPERM: operation not permitted, unlink ‘C:\Users\manish jha\AppData\Roaming\npm\node_modules\.staging\typescript-dd2c5bdd\lib\tsc.js’
    npm ERR! errno: -4048,
    npm ERR! code: ‘EPERM’,
    npm ERR! syscall: ‘unlink’,
    npm ERR! path:
    npm ERR! ‘C:\\Users\\manish jha\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-dd2c5bdd\\lib\\tsc.js’ },
    npm ERR! stack:
    npm ERR! ‘Error: EPERM: operation not permitted, unlink \’C:\\Users\\manish jha\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-dd2c5bdd\\lib\\tsc.js\”,
    npm ERR! errno: -4048,
    npm ERR! code: ‘EPERM’,
    npm ERR! syscall: ‘unlink’,
    npm ERR! path:
    npm ERR! ‘C:\\Users\\manish jha\\AppData\\Roaming\\npm\\node_modules\\.staging\\typescript-dd2c5bdd\\lib\\tsc.js’,
    npm ERR! parent: ‘@angular/cli’ }
    npm ERR!
    npm ERR! The operation was rejected by your operating system.
    npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
    npm ERR! or that you lack permissions to access it.
    npm ERR!
    npm ERR! If you believe this might be a permissions issue, please double-check the
    npm ERR! permissions of the file and its containing directories, or try running
    npm ERR! the command again as root/Administrator (though this is not recommended).

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:\Users\manish jha\AppData\Roaming\npm-cache\_logs\2018-12-04T17_05_25_138Z-debug.log

    Please sir Help me. again again facing this error. please solve my problem

  7. bindu says:

    I bought two courses both have problem running. Testing jasmine /angular keep saying node modules are empty.

  8. help says:

    The operation was rejected by your operating system

Leave a Reply

Connect with Me
  • Categories
  • Popular Posts