nwutils/nw-builder

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/my-path/nw-app/node_modules/nw-builder/get/decompress.js'

luminecs opened this issue · 3 comments

The first time I use nw-builder, the command npm run dev is normal, but the command npm run build reports this error.

source code repo: https://github.com/luminecs/test-nw-builder

"scripts": {
    "dev": "nw src/",
    "build": "nwbuild --mode=build --platforms win64,osx64,linux64 --buildDir dist/ src/"
  },

Are there no problems with the paths of index and get?

image

Issue Type

  • Bug Report
  • Feature Request
  • Other

Current/Missing Behaviour

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/my-path/nw-app/node_modules/nw-builder/get/decompress.js' imported from /my-path/nw-app/node_modules/nw-builder/index.js
at new NodeError (node:internal/errors:372:5)
at finalizeResolution (node:internal/modules/esm/resolve:437:11)
at moduleResolve (node:internal/modules/esm/resolve:1009:10)
at defaultResolve (node:internal/modules/esm/resolve:1218:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ModuleWrap. (node:internal/modules/esm/module_job:80:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'

Expected/Proposed Behaviour

Additional Info

  • Package version: 4.2.2
  • Operating System: Fedora Linux 37 (Workstation Edition) 64bit
  • Node version: v16.15.1
  • NW.js version: 0.75.0
  • Repro link:
  • ...

Could you try Node 18 or adding "type": "module" to your package.json? Also the command line options you're using is for v3. Check out the docs to learn how to configure for v4.

Thanks for your reply.
I did it again, still getting this error. And is there a detailed tutorial?

$ npm run b

> helloworld@1.0.0 b
> nwbuild --mode=build --version=latest --flavor=normal --platform=linux --arch=x64 --downloadUrl=https://dl.nwjs.io --manifestUrl=https://nwjs.io/versions --cacheDir=./cache --outDir=./out --cache=true --ffmpeg=false --glob=false /src

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/my-path/test-nw-builder/node_modules/nw-builder/get/decompress.js' imported from /my-path/test-nw-builder/node_modules/nw-builder/index.js
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:326:11)
    at moduleResolve (node:internal/modules/esm/resolve:945:10)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.16.0

Seems like this is caused by nwbuild executing index.js instead of cli.js. Even after executing node ./node-modules/nw-builder/src/cli.js this error occured. It worked after adding ./src to all imports in node-modules/nw-builder/index.js.

Executing from JS works as well via import nwbuild from "nw-builder".