Laravel-mix: Can鈥檛 compile TypeScript; requires Webpack 4

Created on 12 Jun 2018  路  4Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 2.1.11
  • Node Version: 8.9.4
  • NPM Version: 5.6.0
  • OS: Windows

Description:

Brand new Laravel project. Trying to compile a JavaScript file using TypeScript. Throws the following error:

ERROR in ./resources/assets/js/src/order.ts
Module build failed: Error: You may be using an old version of webpack; please check you're using at least version 4
    at successfulTypeScriptInstance (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\instances.js:168:15)
    at Object.getTypeScriptInstance (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\instances.js:51:12)
    at Object.loader (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\index.js:16:41)
 @ ./resources/assets/js/app.js 1:0-32
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

Steps To Reproduce:

  1. Create a brand new Laravel project (composer create-project laravel/laravel).
  2. Add a tsconfig.json file with the following contents:
{
    "include": [
        "resources/assets/js/**/*"
    ]
}
  1. Try to compile JavaScript file as TypeScript: mix.ts('resources/assets/js/app.js', 'public/js')
  2. Receive error about needing webpack 4.

I don鈥檛 think I鈥檝e _ever_ got TypeScript to compile successfully. It would be good if the Mix documentation could be updated with the minimum options needed to get TypeScript to compile successfully.

Most helpful comment

You should be using ts-loader v3.5, update your package.json

Right now laravel-mix does not support webpack 4

All 4 comments

You should be using ts-loader v3.5, update your package.json

Right now laravel-mix does not support webpack 4

@ankurk91 Thank you.

Hi @JeffreyWay, is there any way to specify the version of the typescript's dependencies (at this line) ?

Otherwise, upgrading webpack to v4 may solve the issue

Cheers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nezaboravi picture nezaboravi  路  3Comments

dtheb picture dtheb  路  3Comments

mementoneli picture mementoneli  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

amin101 picture amin101  路  3Comments