When I try to build my project running the following command:
ng build --environment=prod --aot=false --output-pa
Faced the same issue and solved by executing the npm link command.
When we run
npm linkin a module’s root directory, npm creates a symbolic link from our “global node_modules” directory to the local module’s directoryThe “global node_modules” directory is a special directory where all modules installed with
npm install -gare stored. We can find the path to our global node_modules directory by runningnpm root -g
Visit :- https://medium.com/@alexishevia/the-magic-behind-npm-link-d94dcb3a81af
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.
@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/
Stupid fix
Removing node_modules and installing the packages again npm i or yarn worked for me!
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).
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
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
check if you have node_modules folder on project folder.