Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Asked Answered
N

6

11

I have created an application on angular 7 and ionic 4. I tried to edit app.routing.ts file, setting path and component. From then on I am getting this error below:

ERROR in ./src/app/department/department.module.ts
[ng] Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
[ng] Error: ENOENT: no such file or directory, open 'C:\Users\x\department\department.module.ts'
[ng]     at Object.openSync (fs.js:436:3)
[ng]     at Object.readFileSync (fs.js:341:35)
[ng]     at Storage.provideSync (C:\Users\x\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:98:13)
Nik answered 17/6, 2019 at 10:27 Comment(0)
B
2

Make sure department component exist, check the templateUrl that corresponds to the file name you are referencing. You may have also modified the path unknowingly during modification of app.routing.ts file.

C:\Users\x\department\department.module.ts

Bruise answered 20/9, 2019 at 11:20 Comment(0)
Q
1

This error occurs when your component can't be found with your app.module settings.

Follow these steps to solve your problem:

  1. Check if the module.ts file exists.
  2. Check the relative path.
  3. The path is case sensitive (maybe the .ts file is Department).
Quadruped answered 3/10, 2019 at 9:19 Comment(0)
R
0

Both answer are useful from @trustidkid and @vinay sharma. If there is someone has been facing the same problem; 1-Go to to the file that the error has occurred in. (To go directly to the file, click the error line shortly [CTRL+Click] (CMD+Click on MacOS):

ERROR in ./src/app/department/department.module.ts

Then check the path address if it is exactly true pointing the file. Most of these problems are having similar solutions. Just be sure about the path address of the file you want to point and the address mentioned in the other file which the error occurred.

Remotion answered 14/10, 2019 at 7:25 Comment(0)
M
0

This problem happens when you delete a component but forgot to delete its import from module.ts.

For example: TestComponent is deleted so you have to also delete:

import { TestComponent } from './test.component'
Muoimuon answered 19/9, 2020 at 11:24 Comment(0)
N
0

If you have a folder mapping on a windows machine like me, do not try to build it from a mapped folder, go to the original folder and build it from there. Mapped Folder has a small icon like this:

Mapped Folder

Nadler answered 20/10, 2020 at 22:45 Comment(0)
W
0

In my case I had prime ng version that did not support a particular module, I simply commented it out and it worked.

Wimmer answered 13/11, 2021 at 23:42 Comment(1)
If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From ReviewAnimism

© 2022 - 2024 — McMap. All rights reserved.