danmarshall / jscad-now

🧱👀 Instantly view a jscad V2 module while coding
MIT License
22 stars 6 forks source link

Can't walk dependency graph: Cannot find module #22

Closed tyler71 closed 11 months ago

tyler71 commented 11 months ago

Using Ubuntu 22.04. Trialed installing locally, globally, with npm & yarn.

Reproducible error:

$ docker container run -it node bash

$ npm install -g jscad-now
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated

added 351 packages in 8s

34 packages are looking for funding
  run `npm fund` for details

$ git clone https://github.com/danmarshall/jscad-now
Cloning into 'jscad-now'...
remote: Enumerating objects: 332, done.
remote: Counting objects: 100% (55/55), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 332 (delta 21), reused 22 (delta 9), pack-reused 277
Receiving objects: 100% (332/332), 193.91 KiB | 5.88 MiB/s, done.
Resolving deltas: 100% (157/157), done.

$ cd jscad-now/
$ jscad-now test/index.js 
[0000] info  Server running at http://127.0.0.1:8099/ (connect)
[0000] info  LiveReload running
press ENTER to close server and clean up "jscad-now.js" project file
Error: Can't walk dependency graph: Cannot find module 'test/index.js' from '/jscad-now/jscad-now.js'
    required by /jscad-now/jscad-now.js
    at /usr/local/lib/node_modules/jscad-now/node_modules/resolve/lib/async.js:146:35
    at processDirs (/usr/local/lib/node_modules/jscad-now/node_modules/resolve/lib/async.js:299:39)
    at isdir (/usr/local/lib/node_modules/jscad-now/node_modules/resolve/lib/async.js:306:32)
    at /usr/local/lib/node_modules/jscad-now/node_modules/resolve/lib/async.js:34:69
    at FSReqCallback.oncomplete (node:fs:199:21) {
  code: 'MODULE_NOT_FOUND',
  stream: [Labeled]
}

exiting, please wait...
tyler71 commented 11 months ago

not specifying the js file defaults to index.js, and this does work It appears that specifying the path causes the issue

Eg

$ jscad-now
[0000] info  Server running at http://192.168.10.71:8099/ (connect)
[0000] info  LiveReload running
press ENTER to close server and clean up "jscad-now.js" project file
[0002] 2246ms     4.6MB (browserify)

$ scad-now index.js
[0000] info  Server running at http://192.168.10.71:8099/ (connect)
[0000] info  LiveReload running
press ENTER to close server and clean up "jscad-now.js" project file
Error: Can't walk dependency graph: Cannot find module 'index.js' from '/ram/jscad-now/test/jscad-now.js'
    required by /ram/jscad-now/test/jscad-now.js
    at /home/z/.config/yarn/global/node_modules/resolve/lib/async.js:146:35
    at processDirs (/home/z/.config/yarn/global/node_modules/resolve/lib/async.js:299:39)
    at isdir (/home/z/.config/yarn/global/node_modules/resolve/lib/async.js:306:32)
    at /home/z/.config/yarn/global/node_modules/resolve/lib/async.js:34:69
    at FSReqCallback.oncomplete (node:fs:199:21) {
  code: 'MODULE_NOT_FOUND',
  stream: [Labeled]
}

$ mv index.js index.js2
$ jscad-now                                                                                                                                           test -> main — ! ? RC=1
Error: ENOENT: no such file or directory, stat '/ram/jscad-now/test/index.js'
    at Object.statSync (node:fs:1710:3)
    at Object.<anonymous> (/home/z/.config/yarn/global/node_modules/jscad-now/src/server/index.js:11:6)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Function.Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/home/z/.config/yarn/global/node_modules/jscad-now/bin/cli.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1241:14) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/ram/jscad-now/test/index.js'
}
input file "./index.js" does not exist