Reputation: 17895
Generated Angular project with CLI
Modified tsconfig
, added strict options
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"strict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"]
}
}
When running ng serve
I get following error:
ERROR in src/app/app.component.ts(2,29): error TS7016: Could not find a declaration file for module 'util'. 'D:/proj/node_modules/util/util.js' implicitly has an 'any' type. Try
npm install @types/util
if it exists or add a new declaration (.d.ts) file containingdeclare module 'util';
I tried npm install
suggested - this module does not exist.
I also tried to delete node_modules and do npm install
. Same thing. Any pointers?
EDIT
app.component.ts
import { Component, OnInit } from "@angular/core";
import { isUndefined } from "util";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"]
})
export class AppComponent {
title = "Portal";
}
Upvotes: 8
Views: 7596
Reputation: 81
Just comment out or remove the following line from main.ts (added by the upgrade process):
export { renderModule, renderModuleFactory } from '@angular/platform-server';
might be resolved your problem
Upvotes: 0
Reputation: 15
Declare variables before assigning any values in strict mode:
var title = "portal";
or
let title = "portal"
Upvotes: -4
Reputation: 9913
try this:
1: Delete node_modules
2: Run npm install
3: Run ng serve --aot=false
Hope it will help you.
Upvotes: 1