project-chip / matter.js

A complete typescript implementation of the Matter protocol specification (https://buildwithmatter.com). Includes full support for controller, device, commissioning, secure communications, device types, and cluster definitions.
Apache License 2.0
353 stars 60 forks source link

macOS: Cannot find module when running examples #1343

Closed leonardocavagnis closed 4 days ago

leonardocavagnis commented 4 days ago

Problem description: Running npm run matter-device on macOS results in a MODULE_NOT_FOUND error.

@ examples % sudo npm run matter-device               

> @matter/examples@0.0.0-git matter-device
> matter-run src/examples/device-onoff-cli/DeviceNode.ts

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/Users/leonardocavagnis/Desktop/matter.js/packages/examples/dist/esm/examples/device-onoff-cli/DeviceNode.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.17.0
npm error Lifecycle script `matter-device` failed with error:
npm error code 1
npm error path /Users/leonardocavagnis/Desktop/matter.js/packages/examples
npm error workspace @matter/examples@0.0.0-git
npm error location /Users/leonardocavagnis/Desktop/matter.js/packages/examples
npm error command failed
npm error command sh -c matter-run src/examples/device-onoff-cli/DeviceNode.ts

To reproduce:

git clone https://github.com/project-chip/matter.js.git
cd matter.js  
sudo npm install
cd packages/examples
npm run matter-device

Operating System: macOS Sonoma 14.6.1 (MacBook Pro 2023 - Apple M2 Pro)

Apollon77 commented 4 days ago

Oh, yes seems we forhot to adjust package.jsons after renaming some examples. fix comes

leonardocavagnis commented 4 days ago

I switched on branch https://github.com/project-chip/matter.js/tree/load-descriptor-before-add, but issue persists :(

@ examples % npm run matter-device 

> @matter/examples@0.0.0-git matter-device
> matter-run src/examples/device-onoff/DeviceNode.ts

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/Users/leonardocavagnis/Desktop/matter.js/packages/examples/dist/esm/examples/device-onoff/DeviceNode.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.17.0
npm error Lifecycle script `matter-device` failed with error:
npm error code 1
npm error path /Users/leonardocavagnis/Desktop/matter.js/packages/examples
npm error workspace @matter/examples@0.0.0-git
npm error location /Users/leonardocavagnis/Desktop/matter.js/packages/examples
npm error command failed
npm error command sh -c matter-run src/examples/device-onoff/DeviceNode.ts
Apollon77 commented 4 days ago

grmppff ... forgot to push a last commit ... please pull branch ...

leonardocavagnis commented 4 days ago

@Apollon77 it works like a charm! thanks