Closed ps2-controller closed 4 months ago
Closing the issue - I got it working this way:
import { createRequire } from "module"
import path from 'path';
const require = createRequire(import.meta.url)
const stockfish_path = path.join('node_modules', 'stockfish', 'src', 'stockfish-nnue-16.js')
const load_engine = require('./load_engine.cjs')
from there, following the node_abstractions example in the examples folder
I've taken a look through all the files in the examples folder, as well as all the issues here on github, but they don't make it clear to me how to use stockfish as an npm package in node.js
I think I'm fundamentally approaching this in the wrong way somehow, but it's unclear how.
Specifically, I'm trying to get the best move within a lambda function. I ran npm install stockfish and have the following simple file getBestMove.ts
but when I build my project, I get Module not found: Error: Can't resolve 'stockfish'. I haven't had this issue importing any other modules in my entire project so far and am not treating the stockfish module any differently.