Angular - CodeAnywhere - You seem to not be depending on "@angular/core". This is an error
Asked Answered
S

6

2

Hey im trying to install Angular Cli but i keep getting failed package install. Then i try to start the server and it says You seem to not be depending on "@angular/core". This is an error.

Failed to install package

Strenuous answered 19/2, 2018 at 4:9 Comment(1)
can you please update your question with package.json file ?Jobbery
R
4

Check if you're in the project folder in terminal

Rebekah answered 1/4, 2018 at 15:19 Comment(0)
D
1

first check the node

node -v

and npm are install correctly

npm -v

then try again with

npm install -g npm@latest 

then you add it in ts file

const _core = require("@angular/core");
Danford answered 19/2, 2018 at 5:41 Comment(0)
W
1

This is how I solved this problem on my machine.

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!

Width answered 13/3, 2018 at 21:4 Comment(0)
G
0

First ensure you have @angular/core install, else run:

npm install @angular/core 

This should get @angular/core install in you node_module and also update itself in your package.json. Also ensure that you're not using an old version of node and NPM, else run from your terminal:

npm install npm@latest -g 

Then you can add into your js file .

const core_1 = require("@angular/core");
Grizel answered 19/2, 2018 at 4:46 Comment(0)
D
0

There is some issue with node-sass in codeanywhere due to some permission exceptions. The workaround is go to /usr/lib/node_modules/@angular/cli/ and delete the node_modules folder and then run sudo npm install again create a new project using ng new and try running it . It will work

Dumas answered 18/3, 2018 at 8:51 Comment(0)
D
0

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

Incase if it fails too

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
Defeatist answered 29/5, 2018 at 5:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.