You seem to not be depending on "@angular/core". This is an error
AngularNpmAngular CliAngular Problem Overview
Angular Solutions
Solution 1 - Angular
Try to run
npm install
in the project folder
Solution 2 - Angular
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.
Solution 3 - Angular
Delete your node modules , Check your package.json
file should have the @angular/core
and reinstall it with npm i
.
Solution 4 - Angular
-
Delete node_modules folder and package-lock.json file.
-
Then run following command it will update npm packages.
npm update
-
Later start project executing following command.
ng serve
Above steps worked for me.
Solution 5 - Angular
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.
Solution 6 - Angular
from terminal
> cd myProjectPath
myProjectPath > npm install
Solution 7 - Angular
Below steps worked for me:
-
Delete the
node_modules/
folder andpackage-lock.json
file. -
npm install
-
ng serve
Solution 8 - Angular
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.
Solution 9 - Angular
Solution 10 - Angular
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
Solution 11 - Angular
Run the npm update after installing all peer dependencies and it will work.
Solution 12 - Angular
I got the same issue, and the reason is
- when you run
ng new app-name
it will create a new directory with app name and install everything in that. - 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
Solution 13 - Angular
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.)
Solution 14 - Angular
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!
Solution 15 - Angular
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.
Solution 16 - Angular
After trying to no avail:
- npm install
- npm update
- ng serve
npm install -g @angular/cli worked for me
Solution 17 - Angular
I had the same issue and along with removing the node_modules and reinstalling I needed to remove package-lock.json first.
Solution 18 - Angular
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."
Solution 19 - Angular
You need to run the ng server from the c:\project\angular-src location. Not just the root of your project.
Solution 20 - Angular
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
Solution 21 - Angular
In my case the following worked:
rm -rf node_modules
rm package-lock.json
npm install
Hence the npm install
, not update.
Solution 22 - Angular
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
Solution 23 - Angular
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.
Solution 24 - Angular
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.
Solution 25 - Angular
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/ **
Solution 26 - Angular
**You should be in the newly created YOUR_APP folder before you hit the ng serve command **
Lets start from fresh,
-
install npm
-
create a new angular app (
ng new <YOUR_APP_NAME>
) -
go to app folder (
cd YOUR_APP_NAME
) -
ng serve
I hope it will resolve the issue.