[angular] You seem to not be depending on "@angular/core". This is an error

I want to create an angular 2 App with angular cli

I have written in the cmd:

npm install angular-cli -g

then:

ng firstngapp

but it show me an error when I write npm start ! the error image

Files image

I don't understand the problem

This question is related to angular npm angular-cli

The answer is


Try to run

npm install

in the project folder


This happened to me when I was mixing package managers. My project was generated with Yarn, and after that, I added a couple of dependencies using npm install (this created the package-lock.json with only added dependencies).

Apparently, ng serve used package-lock.json and couldn't find Angular dependencies there. After I started using only Yarn, i.e. yarn add instead of npm install, the error was gone.


If anyone is running into this in 2018, the thing that finally worked for me was to go into the my-app I created with ng new my-app, and THEN run ng serve This has to do with it needing the dependencies and devDependencies located in my-app/package.json instead of root/package.json. They are two separate files.

Even if I copied the all the dependencies to my root folder's package.json, I would also have to go in and manually change the path locations for the config files and such to go into my-app/*. It is much easier to just go into my-app/ and run ng serve there to let it all work like it is supposed to.

So these steps should work for anyone:

rm -rf <previous-app> // Whatever your previous app was called, if you had one.

sudo rm -rf node_modules

rm -f package-lock.json

npm install

ng new my-app

cd my-app

ng serve


I was getting the same error when I tried to run "ng serve" after that I saw some suggetions one of the techie told me to update my npm.I did that as well then I got this screen after entering "ng server"

""Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install. Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_module and package-lock.json(if you have one) and Run npm install again.""

After performing all the actions now its working correctly...and getting message "Compiled Successfully."


May help you.

  • Delete All folders you have created previously
  • Create fresh folder
  • Then try navigate to that folder from command "cd foldername"
  • then try to install "npm install"

This will solve you problem.


  1. Delete node_modules folder and package-lock.json file.
  2. Then run following command it will update npm packages.

    npm update

  3. Later start project executing following command.

    ng serve

Above steps worked for me.


You need to run the ng server from the c:\project\angular-src location. Not just the root of your project.


Delete your node modules , Check your package.json file should have the @angular/core and reinstall it with npm i.


This is how I solved this problem.

I first ran npm install @angular/core.

Then I ran npm install --save.

When both installs had successfully completed I ran npm serve and received an error saying

"Versions of @angular/compiler-cli and typescript could not be determined.
The most common reason for this is a broken npm install.

Please make sure your package.json contains both @angular/compiler-cli and typescript in
devDependencies, then delete node_modules and package-lock.json (if you have one) and
run npm install again."

I then deleted my node_modules folder as well as my package-lock.json folder.

After I deleted those folders I ran npm install --save once more.

I ran npm start and received another error. This error said Error: Cannot find module '@angular-devkit/core'.

I ran npm install @angular-devkit/core --save.

Finally, I ran npm start and the project started!


In my case the following worked:

rm -rf node_modules
rm package-lock.json
npm install

Hence the npm install, not update.


Run the npm update after installing all peer dependencies and it will work.


The problem I had was that I followed the cli's advice to switch to yarn package management.

Then while following a tutorial I did npm install --save bootstrap, and after that point the error started appearing. Afterwards I did yarn add xxx of course and it worked.

To restore the project's state I removed node_modules and package-lock.json as per this answer and then run yarn install


While running ng serve you should be in the app's/project's directory.

If you run the command in another directory you get the error:

You seem to not be depending on "@angular/core". This is an error.


Executing ng new --skip-install PROJECT_NAME and then manually going into the created folder and typing npm install. https://github.com/angular/angular-cli/issues/3906


Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install.

Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_modules and package-lock.json (if you have one) and run npm install again.


I had the same issue and along with removing the node_modules and reinstalling I needed to remove package-lock.json first.


Below steps worked for me:

1) Delete the node_modules/ folder and package-lock.json file.

2) npm install

3) ng serve


You create new project with:

ng new firstngapp

In your example you are missing new. This would create folder, generate files and run npm install for you. It seems that you've created folder but there's no Angular CLI app in it.

And for starting the app use:

ng serve

npm start is only used if you have ejected from cli.


To solve this problem.

  1. Step1: cd projectName
  2. Step2: npm update
  3. Step3: ng serve -o

For example : enter image description here


I don't know if it is still an issue. I was experiencing the same nuisance with @angular/cli v1.1.2 on npm 4.1.2. I deleted the node_modules directory and then went on to updating npm (since this was a common cause in the past).

I wanted to upgrade npm to 5.0.3 (latest) but since I was using nvm it seems to have messed up the libraries. Thus, I reinstalled node.

Then, I went with

  • npm cache clean
  • npm rebuild
  • npm install - This one several times, since every time it threw an error with a different package

In the end, every package was fine.

Hope this helps.


I got the same issue, and the reason is

  1. when you run ng new app-name it will create a new directory with app name and install everything in that.
  2. after running the above command, human tendency is to run ng serve and because your app is in sub directory it will not find package.json and throw the mentioned error.

Solution is pretty simple. just move to the sub directory and then run ng serve


the fix for me was

npm link
ng build 

enter image description here


For ng serve you need to be inside that directory

ashish@ashish-Inspiron-3521:~/Angular$ ng new FireStore
  create FireStore/README.md (1025 bytes)
  create FireStore/.angular-cli.json (1245 bytes)
  create FireStore/.editorconfig (245 bytes)
  create FireStore/.gitignore (544 bytes)
  create FireStore/src/assets/.gitkeep (0 bytes)
  create FireStore/src/environments/environment.prod.ts (51 bytes)
  create FireStore/src/environments/environment.ts (387 bytes)
  create FireStore/src/favicon.ico (5430 bytes)
  create FireStore/src/index.html (296 bytes)
  create FireStore/src/main.ts (370 bytes)
  create FireStore/src/polyfills.ts (3114 bytes)
  create FireStore/src/styles.css (80 bytes)

ashish@ashish-Inspiron-3521:~/Angular$ ng serve
You seem to not be depending on "@angular/core". This is an error.

How I solved this using cmd

ashish@ashish-Inspiron-3521:~/Angular$ cd FireStore/

Now Do cmd

ashish@ashish-Inspiron-3521:~/Angular/FireStore$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Faced the same Issue. While running ngserve you should be in the apps directory. To confirm(on GIT BASH : you will have (master) after the directory path at gitbash prompt, if you are at app directory.)


**You should be in the newly created YOUR_APP folder before you hit the ng serve command **

Lets start from fresh,

1) install npm

2) create a new angular app ( ng new <YOUR_APP_NAME> )

3) go to app folder (cd YOUR_APP_NAME)

4) ng serve

I hope it will resolve the issue.


from terminal

 > cd myProjectPath
 myProjectPath > npm install

After trying to no avail:

  • npm install
  • npm update
  • ng serve

npm install -g @angular/cli worked for me


Examples related to angular

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class error TS1086: An accessor cannot be declared in an ambient context in Angular 9 TS1086: An accessor cannot be declared in ambient context @angular/material/index.d.ts' is not a module Why powershell does not run Angular commands? error: This is probably not a problem with npm. There is likely additional logging output above Angular @ViewChild() error: Expected 2 arguments, but got 1 Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' Access blocked by CORS policy: Response to preflight request doesn't pass access control check origin 'http://localhost:4200' has been blocked by CORS policy in Angular7

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?

Examples related to angular-cli

Why powershell does not run Angular commands? ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found Could not find module "@angular-devkit/build-angular" How to remove package using Angular CLI? How to set environment via `ng serve` in Angular 6 Error: Local workspace file ('angular.json') could not be found How do I deal with installing peer dependencies in Angular CLI? How to iterate using ngFor loop Map containing key as string and values as map iteration how to format date in Component of angular 5