[英]Error: Could not resolve module @angular/core
I am trying to run an angular 4 application but i keep getting this error我正在尝试运行 angular 4 应用程序,但我不断收到此错误
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.
@angular/core 存在于 node_modules 文件夹中。 I have tried with @angular/cli installed and without but no effect on this error.
我试过安装了@angular/cli,但对这个错误没有影响。 I am not sure how to resolve this.
我不知道如何解决这个问题。 It occurs in my amazon ec2 machine but not in my local Mac machine.
它发生在我的亚马逊 ec2 机器上,但不在我的本地 Mac 机器上。 The versions of the libraries are all the same.
库的版本都是一样的。
Any help will be appreciated.任何帮助将不胜感激。 Thanks.
谢谢。
Had the same problem, solved changing the tsconfig, not sure that it will helps, using this now,:遇到了同样的问题,解决了更改 tsconfig 的问题,不确定它是否会有所帮助,现在使用它:
{
"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"
]
}
}
If anyone still facing such issue-如果有人仍然面临这样的问题-
Your package.json may have been corrupt.您的 package.json 可能已损坏。 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).再次安装 angular/core 库(应用程序的特定版本)。
npm i @angular/core
npm install
npm install
What may cause such issue is caused by an incorrect TypeScript configuration.可能导致此类问题的原因是 TypeScript 配置不正确。
Make sure your tsconfig.json has moduleResolution
set to "node"
(rather than eg "classic"
).确保您的tsconfig.json有
moduleResolution
设置为"node"
(而不是如"classic"
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.