This is my first venture into creating an Angular 2 application within MVC Core, utilizing TypeScript 2.2, Angular2, and Webpack.
I have been closely following the Angular Documentation, but despite referencing the latest NPM Modules, I encounter errors when running Webpack:
ERROR in [at-loader]
TS2688: Cannot find type definition file for 'node'.
ERROR in [at-loader] ./src/app/app.component.ts:6:15
TS2304: Cannot find name 'require'.
ERROR in [at-loader] ./src/app/app.component.ts:7:14
TS2304: Cannot find name 'require'.
ERROR in [at-loader] ./src/main.ts:5:5
TS2304: Cannot find name 'process'.
ERROR in [at-loader] ./src/polyfills.ts:3:1
TS2304: Cannot find name 'require'.
ERROR in [at-loader] ./src/polyfills.ts:5:5
TS2304: Cannot find name 'process'.
ERROR in [at-loader] ./src/polyfills.ts:10:5
TS2304: Cannot find name 'require'.
The initial error seems to be the most significant one. After some investigation, I made changes by adding types and typeRoots to my tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"noEmitOnError": true,
"suppressImplicitAnyIndexErrors": true,
"types": [ "node" ],
"typeRoots": [
"node_modules/@types"
]
}
}
Unfortunately, this did not solve the issue. Here is a snippet from my package.json file for reference:
... (excerpt continues)All other files adhere to the instructions provided in the Angular documentation.
Your assistance with resolving this would be greatly appreciated.
Update
By reverting
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e7a777e6b7d6d7c677e7a4e3c203c203f">[email protected]</a>
back to its earlier form <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef9b969f8a9c8c9d869f9bafddc1dfc1dedf">[email protected]</a>
, the project successfully builds without any errors via Webpack. It appears that the problem could stem from either:
- A shift in how TypeScript requires configuration or...
- An alteration in the syntax of user code between versions 2.0 and 2.2
I am surprised that there aren't more individuals encountering this issue. However, it's likely they possess greater knowledge of Webpack and TypeScript than myself!