0

I am attempting to get a webpack to work, following example here: https://angular.io/docs/ts/latest/guide/webpack.html

I have undertaken a remedy flagged in other related posts: "npm install @types/node --save-dev"

So on executing npm start following chunk "polyfill.js" being rendered, there are 6 x TS2304 errors relating to 'Cannot find name require"/or ..."process".
Such as:

ERROR in [at-loader] ./src/app/app.component.ts:5:13 TS2304: Cannot find name 'require'. . .

ERROR in [at-loader] ./src/main.ts:4:5 TS2304: Cannot find name 'process'.

There were more errors previously so I changed typescript version in package.json 2.2, here is package.json:

{
 "name": "angular2-webpack",
 "version": "1.0.0",
 "description": "A webpack starter for Angular",
 "scripts": {
   "start": "webpack-dev-server --inline --progress --port 8080",
   "test": "karma start",
   "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
    },
 "license": "MIT",

"dependencies": {
 "@angular/common": "~4.0.0",
 "@angular/compiler": "~4.0.0",
 "@angular/core": "~4.0.0",
 "@angular/forms": "~4.0.0",
 "@angular/http": "~4.0.0",
 "@angular/platform-browser": "~4.0.0",
 "@angular/platform-browser-dynamic": "~4.0.0",
 "@angular/router": "~4.0.0",
 "core-js": "^2.4.1",
 "rxjs": "5.0.1",
" zone.js": "^0.8.4"
},
"devDependencies": {
 "@types/jasmine": "^2.5.36",
 "@types/node": "^6.0.73",
 "angular2-template-loader": "^0.6.0",
 "awesome-typescript-loader": "^3.0.4",
 "css-loader": "^0.26.1",
 "extract-text-webpack-plugin": "2.0.0-beta.5",
 "file-loader": "^0.9.0",
 "html-loader": "^0.4.3",
 "html-webpack-plugin": "^2.16.1",
 "jasmine-core": "^2.4.1",
 "karma": "^1.2.0",
 "karma-chrome-launcher": "^2.0.0",
 "karma-jasmine": "^1.0.2",
 "karma-sourcemap-loader": "^0.3.7",
 "karma-webpack": "^2.0.1",
 "null-loader": "^0.1.1",
 "raw-loader": "^0.5.1",
 "rimraf": "^2.5.2",
 "style-loader": "^0.13.1",
 "typescript": "~2.2.0",
 "webpack": "2.2.1",
 "webpack-dev-server": "2.4.1",
 "webpack-merge": "^3.0.0"
 }
}

If anyone can assist with their experience with similar errors, that would be helpful! I will post further info if need be.

Thank you...

user7611503
  • 131
  • 1
  • 1
  • 6
  • post your `tsconfig.json` and .`/src/main.ts` use [this answer](http://stackoverflow.com/questions/31173738/typescript-getting-error-ts2304-cannot-find-name-require/35961176#35961176) for the TS2304 – cgatian May 19 '17 at 01:24

1 Answers1

0

ERROR in [at-loader] ./src/app/app.component.ts:5:13 TS2304: Cannot find name 'require'. . . ERROR in [at-loader] ./src/main.ts:4:5 TS2304: Cannot find name 'process'.

Both of these are in @types/node. Make sure your tsconfig is valid.

basarat
  • 261,912
  • 58
  • 460
  • 511
  • Thank you. I saw a link here that appears to be related to this issue and found my answer: http://stackoverflow.com/questions/42133190/ts2304-with-webpack-2-and-angular-2?rq=1 . I added this to my compiler options in tsconfig.json: "typeRoots": ["../node_modules/@types/"] – user7611503 May 21 '17 at 13:32