4

Am quite new to nodejs, so this could be a silly question, but I hope not.

Am trying to import the chessjs library in a simple node app.

I have this :

const Chess = require('chessjs');
var chess = new Chess();

But I get :

Error: Cannot find module './chess.js'

when I run it despite having installed the lib with npm.

thanks

=========== EDIT SOLUTION ====================

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

allafleche
  • 41
  • 2
  • Hi allafleche, take a look at the sample code in the 'chessjs' link you posted and compare it to your code, your require statement is not correct – matto0 Jun 18 '20 at 22:13

1 Answers1

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

This was from their docs

This might help spread light on whats happening. Import with or without curly brackets in ES6

Roman Alekseiev
  • 1,854
  • 16
  • 24
beskgar
  • 355
  • 3
  • 10