#Error module not found

15 messages · Page 1 of 1 (latest)

tough plinth
#
pkg/prelude/bootstrap.js:1872
      throw error;
      ^

Error: Cannot find module 'mineflayer'
Require stack:
- C:\snapshot\boty\test.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1951:46)
    at Module._load (node:internal/modules/cjs/loader:787:27)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at Module.require (pkg/prelude/bootstrap.js:1851:31)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\snapshot\boty\test.js)
    at Module._compile (pkg/prelude/bootstrap.js:1926:22)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\snapshot\\boty\\test.js' ],
  pkg: true
}
abstract swift
#

You deleted the last thread, so it’s not clear whether your intentions are benign

tough plinth
jagged tartan
#

show package.json and your code where you import mineflayer

tough plinth
#

but thanks if youre willing to help

jagged tartan
#

lol npm i mineflayer gets me 87 modules 🙃

#

it seems to work fine for me. I did the following:

  1. npm i mineflayer
  2. Paste the "Echo Example" from here into index.js: https://www.npmjs.com/package/mineflayer
  3. Ran to verify it works node . (this showed a connection error, but "worked")
  4. npm i @yao-pkg/pkg
  5. npx pkg -t node22-win-x64 -o app.exe index.js
  6. Copied the resulting app.exe to a different directory and ran it. It worked the same as step 3.
tough plinth
tough plinth
#

Someone please help...

jagged tartan
#

Do exactly what I did. Don’t “use your file”. If it works, then the problem is “your file”.

tough plinth
jagged tartan
#

did you install axios? did you check where it's required?
yep. pkg doesn't seem to like axios. use fetch 😛

#

so, the right answer is actually to bundle your script

#

write everything, bundle it, then use pkg with the bundled JS