Home > Mobile >  Using the chess.js module in Nuxt
Using the chess.js module in Nuxt

Time:09-17

I am trying to use the chess.js module in a Nuxt app but the installation instructions don't seem to work for Nuxt.

const { Chess } = require('chess.js')
const chess = new Chess()

The above code gives me Chess is not a constructor

Is there any way to convert the chess.js module to work with Nuxt? Could I scoop out its guts from the chess.js script in their repo and make it into a plugin? If so, how would I go about doing that?

CodePudding user response:

You need to use the import syntax and to call new Chess() in mounted().

  • Related