javascript - angular 13: Module not found: Error: Can't resolve 'rxjs/operators' - TagMerge
4angular 13: Module not found: Error: Can't resolve 'rxjs/operators'angular 13: Module not found: Error: Can't resolve 'rxjs/operators'

angular 13: Module not found: Error: Can't resolve 'rxjs/operators'

Asked 10 months ago
1
4 answers

I just solve this issue by correcting the RxJS version to 7.4.0. I hope this can solve others issue as well.

Source: link

0

The app uses the paths in tsconfig to configure importing of the lib:
// root tsconfig.json{  "compilerOptions": {    ...    "paths": {      "@mycompany/my-library": ["dist/my-library"],      "@mycompany/my-library/*": ["dist/my-library/*"]    }  }}
This configuration works for ng serve but fails for ng build --prod with the following error:
ERROR in ./dist/my-library/my-library.ngfactory.jsModule not found: Error: Can't resolve 'my-library' in '/Users/tanya.gray/Projects/my-project/dist/my-library'
I updated the package.json in the library so that the package name was the same as the one used in the root tsconfig:
// my-library package.json{  "name": "my-library",  ...}
Changed to:
// my-library package.json{  "name": "@mycompany/my-library",  ...}

Source: link

0

Hello Guys, I have a project with angular 11.  It still works fine but today I fetch code from Git and run ng serve --o but I get an error Module not found: Error: Can't resolve '@angular/localize/init'.
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve '@angular/localize/init' in 'D:\Projects\Source\philkostse\Admin\DAG.APA.AdminClient\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'web-animations-js' in 'D:\Projects\Source\philkostse\Admin\DAG.APA.AdminClient\src'
This is my tsconfig.json file:
{
  "compileOnSave": false,
  "compilerOptions": {
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "amd",
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}
And my angular version
Angular CLI: 11.2.14
Node: 14.17.5
OS: win32 x64

Angular: 11.2.14
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.14
@angular-devkit/build-angular   0.1102.14
@angular-devkit/core            11.2.14
@angular-devkit/schematics      11.2.14
@angular/cdk                    11.2.13
@angular/http                   7.2.16
@angular/material               7.3.7
@schematics/angular             11.2.14
@schematics/update              0.1102.14
rxjs                            6.6.7
typescript                      4.1.6
I got the same error about Module not found: Error: Can't resolve '@angular/localize/init'. And I fixed it by change "module": "amd" to es2015 in tsconfig.json file.
{
  "compileOnSave": false,
  "compilerOptions": {
    
    "module": "es2015", // Change amd to es2015
    
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

Source: link

0

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.22-1
node: 7.0.0
os: win32 x64
Normally this include a stack trace and some more information.
C:\Projects\ang-cli\toh>ng build
Hash: 9c9110fd5a7a2c9f1e81
Time: 5907ms
chunk    {0} main.bundle.js, main.bundle.map (main) 24.6 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 12.7 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.33 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'app.component.html' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/app.component.ts 19:22-51
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'app.component.css' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/app.component.ts 20:21-49
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/dashboard.component.ts
Module not found: Error: Can't resolve 'dashboard.component.html' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/dashboard.component.ts 26:22-57
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/dashboard.component.ts
Module not found: Error: Can't resolve 'dashboard.component.css' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/dashboard.component.ts 27:21-55
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/heroes.component.ts
Module not found: Error: Can't resolve 'heroes.component.html' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/heroes.component.ts 58:22-54
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/heroes.component.ts
Module not found: Error: Can't resolve 'heroes.component.css' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/heroes.component.ts 59:21-52
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/hero-detail.component.ts
Module not found: Error: Can't resolve 'hero-detail.component.html' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/hero-detail.component.ts 45:22-59
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/hero-detail.component.ts
Module not found: Error: Can't resolve 'hero-detail.component.css' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/hero-detail.component.ts 46:21-57
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/hero-search.component.ts
Module not found: Error: Can't resolve 'hero-search.component.html' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/hero-search.component.ts 47:22-59
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/hero-search.component.ts
Module not found: Error: Can't resolve 'hero-search.component.css' in 'C:\Projects\ang-cli\toh\src\app'
 @ ./src/app/hero-search.component.ts 48:21-57
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main
@gelliott181, thank you so much for your guidance. It was a great help! It allowed the build process to complete. I really appreciate your sharing that tip.
C:\Projects\ang-cli\toh>ng build
Hash: ca7e2b77d9aa5e9e0a32
Time: 5984ms
chunk    {0} main.bundle.js, main.bundle.map (main) 30.3 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 12.7 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.33 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
After everything built, I thought it was my lucky day, so I decided to go ahead and launch the app. Yeah! Here we go!
C:\Projects\ang-cli\toh>ng serve
** NG Live Development Server is running on http://localhost:4200. **
Hash: 6913a42ec4719e776fd5
Time: 6374ms
chunk    {0} main.bundle.js, main.bundle.map (main) 30.3 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 12.7 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.56 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
webpack: bundle is now VALID.
Uh-oh! Unfortunately, it was not my lucky day. No Joy, Houston! No Joy! The app got stuck loading and threw a nasty little console error related to module id.
Uncaught Error: moduleId should be a string in "AppComponent". See https://goo.gl/wIDDiL for more information.
If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.
    at componentModuleUrl (http://localhost:4200/vendor.bundle.js:24954:15)
    at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (http://localhost:4200/vendor.bundle.js:24306:25)
    at CompileMetadataResolver._loadDirectiveMetadata (http://localhost:4200/vendor.bundle.js:24242:42)
    at http://localhost:4200/vendor.bundle.js:24508:87
    at http://localhost:4200/vendor.bundle.js:24423:99
    at Array.map (native)
    at CompileMetadataResolver.loadNgModuleMetadata (http://localhost:4200/vendor.bundle.js:24423:68)
    at RuntimeCompiler._loadModules (http://localhost:4200/vendor.bundle.js:36514:41)
    at RuntimeCompiler._compileModuleAndComponents (http://localhost:4200/vendor.bundle.js:36484:35)
    at RuntimeCompiler.compileModuleAsync (http://localhost:4200/vendor.bundle.js:36474:21)

Source: link

Recent Questions on javascript

    Programming Languages