DEV Community

loading...

Discussion on: Converting a JavaScript project to Typescript, one file at a time

Collapse
hellfiresteve profile image
hellfireSteve • Edited

I have tried to follow this, but loads was missing. It started to go wrong here:

npm install --save-dev webpack.
warnings: npm WARN ts-loader@5.2.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@6.0.0 but none is installed. You must install peer dependencies yourself.

solved that using the following:

npm install ajv@6.0.0
npm install typescript
npm install ts-loader

Now, when I run npm run build, I get the following failure:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.module has an unknown property 'loaders'. These properties are valid: object { defaultRules?, exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, strictExportPresence?, strictThisContextOnImports?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? } -> Options affecting the normal modules (NormalModuleFactory). Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! playground@1.0.0 build: webpack --config webpack.config.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the playground@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Collapse
hellfiresteve profile image
hellfireSteve

had to change loaders to rules in webpack.config.js:

module: {
rules: [
{ test: /.ts(x?)$/, loader: 'ts-loader' },

{ test: /.json$/, loader: 'json-loader' }
]