Reputation: 7748
I am trying to run an angular 4 application but i keep getting this error
ERROR in Could not resolve module @angular/core
There are no other errors. No dependency errors nothing. @angular/core exists in the node_modules folder. I have tried with @angular/cli installed and without but no effect on this error. I am not sure how to resolve this. It occurs in my amazon ec2 machine but not in my local Mac machine. The versions of the libraries are all the same.
Any help will be appreciated. Thanks.
Upvotes: 11
Views: 14040
Reputation: 129
Had the same problem, solved changing the tsconfig, not sure that it will helps, using this now,:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
Upvotes: 2
Reputation: 11
What may cause such issue is caused by an incorrect TypeScript configuration.
Make sure your tsconfig.json has moduleResolution
set to "node"
(rather than e.g. "classic"
).
Upvotes: 0
Reputation: 358
If anyone still facing such issue-
Your package.json may have been corrupt. Follow the below steps:
Clean/clear the cache. To clear the cache, run the below command.
npm cache clean --force
Install angular/core library again (specific version of your application).
npm i @angular/core
npm install
Upvotes: 4