Error:
src/app/app.component.ts:4:12 - error TS2591: Cannot find name 'module'. Do you need to install type definitions for node? Try
npm i @types/node
and then addnode
to the types field in your tsconfig.4 moduleId: module.id,
When I try to run "ng build" in order to compile my angular files, I get error for every occurance of "module" var usage. I am sure the module is there, I can see it in node_modules folder and also I can ctrl+click on it and the file with module var would open.
I tried deleting whole node_modules dir and install again.
I left my tsconfig.json untouched since I am just learning so far, but here it is:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
here is example of usage in ts component:
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app',
templateUrl: 'app.component.html'
})
export class AppComponent { }
Maybe it has something to do with my project structure, since I am not very sure what project structure to use. I am trying to build spring + angular aplication, with following structure:
Structure of angular app should be alright since it is generated by ng new command
Output path in angular.json is set to "outputPath": "../public", which should be in resource dir.
Do you have any idea what could be wrong please?