Issue
SHORT: Renaming a service or component is no problem, but can you also move it to another folder?
LONG: This is the service I generated at the wrong directory with the ng new service data
command:
When I move it from the src
folder into the _service
folder I'm getting asked, if I want to update the imports. Of course I press yes
, but when starting the app I get this error:
Module build failed (from ./node_modules/@ngtools/webpack/src/
index.js):
Error: ENOENT: no such file or directory ...\data.service.ts
So I checked the index.js
file, if I could update the path to data.service.ts manually, but that's not possible as this is all that is in the index.js
file:
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./angular_compiler_plugin"));
__export(require("./interfaces"));
var loader_1 = require("./loader");
exports.default = loader_1.ngcLoader;
exports.NgToolsLoader = __filename;
Solution
TL;DR: Auto updating imports doesn't seem to work for nested Angular component folders and the error is useless. Check that those imports were updated correctly (anything in the _components folder in the poster's example).
I just ran into this same issue. I'm using the "Move TS" VSCode Extension, and it doesn't appear to update imports in components that are grouped by folders. For example, consider the following folder structure:
> Component 1
> Component 2
> Forms
> Name Component
> Email Component
> Services
api.service.ts
When I moved api.service.ts from its current location into the Services folder, the extension updated the imports in Component 1 and Component 2 correctly. However, it failed to update the imports in the Name Component and the Email Component correctly. I would guess the native VS Code "Update Imports" option has the same defect. So I would check your _components folder to ensure the imports were updated correctly.
Answered By - Evan Kleiner
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.