64

When I try to build my project running the following command:

ng build --environment=prod --aot=false  --output-path="..." --base-href="..."

You seem to not be depending on @angular/core.

This is an error, however, I don't understand why because before it worked well.

I tried to do this:

npm install @angular/core 

But I get this error :

error at Error (native) error { Error: EACCES: permission denied, chown '' error at Error (native) error errno: -13, error code: 'EACCES', error syscall: 'chown', error Please try running this command again as root/Administrator. verbose exit [ -13, true ]

I also tried to get rid of node_modules, then make an install npm: but I get the same error.

And when I run the following command:

ng serve

I have another error:

The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'

This is my package.json :

"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"

"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/jquery": "^3.2.17",
"cli-color": "^1.2.0",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"matrix-js-sdk": "^0.8.5",
"moment": "^2.18.1",
"olm": "https://matrix.org/packages/npm/olm/olm-2.2.2.tgz",
"readline": "^1.3.0",
"rxjs": "^5.4.1",
"socket.io-client": "^2.0.3",
"zone.js": "^0.8.14"

"@angular/cli": "1.2.6",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/jquery": "^3.2.17",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
RobC
  • 22,977
  • 20
  • 73
  • 80
Floriane
  • 671
  • 1
  • 5
  • 9
  • Have you tried any of the solutions here? https://stackoverflow.com/questions/48859420/angular-codeanywhere-you-seem-to-not-be-depending-on-angular-core-this-i OR here https://stackoverflow.com/questions/41421474/why-am-i-receiving-the-following-error-message-when-running-the-ng-serve-command ALSO here https://stackoverflow.com/questions/46452956/you-seem-to-not-be-depending-on-angular-core-typescript – Narm Mar 28 '18 at 14:55
  • @Narm Yes I have already tested these solutions, but I have the same error when I do that : `npm install @angular/core` – Floriane Mar 28 '18 at 14:57
  • Great, glad you've at least tried those solutions. Aside from the posted links I don't have any info on this one for you, sorry. I'll upvote your question and hopefully get it some more attention. Although the other questions never seemed to have an accepted answer, hopefully you will! – Narm Mar 28 '18 at 15:03
  • 2
    `ng update @angular/core` solved my problem – Mustafa Sadedil May 06 '18 at 22:00

9 Answers9

132

Not sure whether below approach will solve your problem or not, please try once.

I have also faced the same issue while executing below command.

D:\My_Project>ng serve

Then I have followed below steps and it worked for me.

D:\My_Project>npm link
D:\My_Project>ng serve

If this is not working kindly let me know I will try to reproduce the error which you are getting and try to give you solution as soon as possible.

Sunil Kumar Sahu
  • 1,515
  • 1
  • 8
  • 14
  • 4
    @AlikElzin-kilaka, Great, It worked, Thank u very much for upvoting. Kindly check below links to know more about it https://docs.npmjs.com/cli/link, http://justjs.com/posts/npm-link-developing-your-own-npm-modules-without-tears – Sunil Kumar Sahu May 21 '18 at 04:12
  • Thanks, you saved my time! :) – Nisha Jul 31 '18 at 15:18
  • 1
    you might have to use `sudo npm link` in case you get a permission error. – Srujan Simha Jan 21 '19 at 21:59
  • Thanks. My system was a windows 10, I had the same issue as above and running npm link worked, upvoted your answer. I ran the command (npm link) in my project (VS code prompt) and after the command ran I see my project folder copy is present in the global node_modules directory. What I don't understand is why does having a copy of the project in the global node_modules solve the problem? Would you know? BTW, I got the problem when I installed a local bootstrap, things were good before that. – user132797 Nov 13 '19 at 05:33
29

How to use

Run npm install inside this project folder to install all dependencies.

Make sure you use the latest version of the CLI (upgrade guide below)

Run ng serve to see the app in action (try npm start in case ng serve fails).

How to upgrade the CLI

Run the below commands - only use "sudo" on Mac/ Linux.

sudo npm uninstall -g angular-cli @angular/cli

npm cache clean --force

sudo npm install -g @angular/cli

In case it fails

Delete node_modules folder and package-lock.json file from your project directory Run the below commands in the given order-

npm install

npm install --save-dev @angular-devkit/build-angular

npm link
adiga
  • 34,372
  • 9
  • 61
  • 83
RookRaven
  • 505
  • 7
  • 12
9

I went down the list of installing the various dependencies as prompted in the terminal. I am running on Windows so I also installed windows Build Tools.

I ran ng serve and got "You seem to not be depending on "@angular/core" and/or "rxjs". This is an error."

Then ran

npm link

followed by

ng serve

Everything is now running. Not sure how much of what I did was necessary/redundant but I can now build Angular projects.

Michael Neely
  • 361
  • 4
  • 5
2

Faced the same issue and solved by executing the npm link command.

When we run npm link in a module’s root directory, npm creates a symbolic link from our “global node_modules” directory to the local module’s directory

The “global node_modules” directory is a special directory where all modules installed with npm install -g are stored. We can find the path to our global node_modules directory by running npm root -g

Visit :- https://medium.com/@alexishevia/the-magic-behind-npm-link-d94dcb3a81af

RobC
  • 22,977
  • 20
  • 73
  • 80
2

Stupid fix

Removing node_modules and installing the packages again npm i or yarn worked for me!

Ben Winding
  • 10,208
  • 4
  • 80
  • 67
0

@Sunil Kumar Sahu is correct.

Using "ng link" means it connects your current application to your root/parent application that you have on your machine. When you run your application, any changes you make to the dependency will be reflected in the application.

After this, just run "ng serve".

Link : https://codurance.com/2016/12/21/how-to-use-npm-link/

  • Prakhar
0

check if you have node_modules folder on project folder.

Wiwern95
  • 65
  • 1
  • 4
0

just try using this code to disable depending @angular/core and/or rxjs

type this:

ng config -g cli
Amirhossein Yari
  • 2,054
  • 3
  • 26
  • 38
shao
  • 1
-4

faced same issue but solve such as by typing 1. npm link and then 2. ng serve if you still face issue then contact me...