Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack - Property context does not exist on type NodeRequire

I want to use: require.context('../images/', true, /\.(png|ico|svg|jpg|gif)$/)

but I get the following error:

Property context does not exist on type NodeRequire

like image 719
Legends Avatar asked Feb 22 '18 19:02

Legends


2 Answers

And in tsconfig.json add it in the types property example:

 {   "compilerOptions": {     "outDir": "./dist/",     "declaration": true,     "declarationDir": "./dist/",     "sourceMap": true,     "noImplicitAny": false,     "module": "commonjs",     "target": "es6",     "allowJs": false,     "types": [       "node",       "webpack-env" // here     ]   },   "files": [     "src/index.ts"   ],   "compileOnSave": false } 
like image 38
JoaquinBu Avatar answered Sep 20 '22 10:09

JoaquinBu


Solution from 2018:

Just install the typings for webpack-env

npm i @types/webpack-env -D 
like image 180
Legends Avatar answered Sep 23 '22 10:09

Legends