简体   繁体   English

错误:无法解析模块@angular/core

[英]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:请按照以下步骤操作:

  1. Delete node_module folder.删除 node_module 文件夹。
  2. Clean/clear the cache.清理/清除缓存。 To clear the cache, run the below command.要清除缓存,请运行以下命令。

    npm cache clean --force

  3. Install angular/core library again (specific version of your application).再次安装 angular/core 库(应用程序的特定版本)。

    npm i @angular/core

  4. Again run 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.

相关问题 找不到Angular 6 setTimeout模块:错误:无法解析'timers' - Angular 6 setTimeout Module not found: Error: Can't resolve 'timers' angular 13:找不到模块:错误:无法解析“rxjs/operators” - angular 13: Module not found: Error: Can't resolve 'rxjs/operators' “找不到模块:错误:无法解析模块”签名请求客户端角度中的错误 - "Module not found: Error: Cannot resolve module" error in signrequest-client angular 找不到模块:错误:无法解析“core-js/modules/es.error.cause.js” - Module not found: Error: Can't resolve 'core-js/modules/es.error.cause.js' 错误:无法解析模块...无法在项目或这些目录中找到:node_modules - Error: Unable to resolve module ... could not be found within the project or in these directories: node_modules 如何修复 Nuxt 3 模块:无法解析“#app” - How to fix Nuxt 3 Module: Could not resolve "#app" Awilix中出现错误“无法解析容器” - Error “Could not resolve container” in Awilix 模块构建失败:错误:无法解析在引导程序版本配置为 v3 时必须安装的模块“bootstrap-sass” - Module build failed: Error: Could not resolve module 'bootstrap-sass' which must be installed when bootstrap version is configured to v3 Require / Angular / Karma / ui-router-错误:无法从状态解析“着陆” - Require / Angular / Karma / ui-router - Error: Could not resolve 'landing' from state '' Angular UI路由器-使用参数“无法解析状态” - Angular UI Router - “could not resolve state” with parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM