jcane86/motor-hat

Installation failing on Raspberry Pi 4, node v12.16.1, npm 6.13.4

nrbrt opened this issue · 5 comments

nrbrt commented

I have seen that there is another ticket open for node 13.9.0, but I thought it was worth opening a new ticket for the stable version of node. It starts with the i2c-bus version. That does not work. I have tried forking ang changing the version to 5.1.0, but that opens a whole new can of worms. Is there any way to get this working? What version of node does it work on?

edit:
I have tried your suggestion from the other ticket and installed using:
npm install github:jcane86/motor-hat#greenkeeper/i2c-bus-2.0.0
and that command finishes successfully, but the node_modules/motor-hat directory only contains The license, readme.md and package.json at that point.

npm list:

motor@1.0.0 /home/pi/node-projects/motor
└─┬ motor-hat@1.0.0-semanticrelease (github:jcane86/motor-hat#f64a863e6ad02a19f731df489c3b7bb15f54ba8e)
  ├── async@3.2.0
  ├─┬ debug@4.1.1
  │ └── ms@2.1.2
  ├─┬ i2c-bus@5.1.0
  │ ├─┬ bindings@1.5.0
  │ │ └── file-uri-to-path@1.0.0
  │ └── nan@2.14.0
  ├─┬ parambulator@1.5.2
  │ ├─┬ gex@0.2.2
  │ │ └── lodash@3.10.0
  │ ├── jsonic@0.2.2
  │ └── lodash@4.5.0
  ├── raspi-ver@1.1.1
  └─┬ sleep@6.1.0
    └── nan@2.14.0 deduped

I also tried going into that directory and running npm install and after that npm run build. The error that showed up was this:

> motor-hat@1.0.0-semanticrelease prebuild /home/pi/node-projects/motor/node_modules/motor-hat
> rimraf dist


> motor-hat@1.0.0-semanticrelease build /home/pi/node-projects/motor/node_modules/motor-hat
> babel --copy-files --out-dir dist --ignore test/ lib

lib doesn't exist
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! motor-hat@1.0.0-semanticrelease build: `babel --copy-files --out-dir dist --ignore test/ lib`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the motor-hat@1.0.0-semanticrelease build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2020-03-18T18_11_43_856Z-debug.log

The debug log contains this:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@6.13.4
3 info using node@v12.16.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle motor-hat@1.0.0-semanticrelease~prebuild: motor-hat@1.0.0-semanticrelease
6 verbose lifecycle motor-hat@1.0.0-semanticrelease~prebuild: unsafe-perm in lifecycle true
7 verbose lifecycle motor-hat@1.0.0-semanticrelease~prebuild: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pi/node-projects/motor/node_modules/motor-hat/node_modules/.bin:/home/pi/node-projects/motor/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
8 verbose lifecycle motor-hat@1.0.0-semanticrelease~prebuild: CWD: /home/pi/node-projects/motor/node_modules/motor-hat
9 silly lifecycle motor-hat@1.0.0-semanticrelease~prebuild: Args: [ '-c', 'rimraf dist' ]
10 silly lifecycle motor-hat@1.0.0-semanticrelease~prebuild: Returned: code: 0  signal: null
11 info lifecycle motor-hat@1.0.0-semanticrelease~build: motor-hat@1.0.0-semanticrelease
12 verbose lifecycle motor-hat@1.0.0-semanticrelease~build: unsafe-perm in lifecycle true
13 verbose lifecycle motor-hat@1.0.0-semanticrelease~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pi/node-projects/motor/node_modules/motor-hat/node_modules/.bin:/home/pi/node-projects/motor/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
14 verbose lifecycle motor-hat@1.0.0-semanticrelease~build: CWD: /home/pi/node-projects/motor/node_modules/motor-hat
15 silly lifecycle motor-hat@1.0.0-semanticrelease~build: Args: [ '-c', 'babel --copy-files --out-dir dist --ignore test/ lib' ]
16 silly lifecycle motor-hat@1.0.0-semanticrelease~build: Returned: code: 2  signal: null
17 info lifecycle motor-hat@1.0.0-semanticrelease~build: Failed to exec build script
18 verbose stack Error: motor-hat@1.0.0-semanticrelease build: `babel --copy-files --out-dir dist --ignore test/ lib`
18 verbose stack Exit status 2
18 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
18 verbose stack     at EventEmitter.emit (events.js:311:20)
18 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
18 verbose stack     at ChildProcess.emit (events.js:311:20)
18 verbose stack     at maybeClose (internal/child_process.js:1021:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
19 verbose pkgid motor-hat@1.0.0-semanticrelease
20 verbose cwd /home/pi/node-projects/motor/node_modules/motor-hat
21 verbose Linux 4.19.97-v7l+
22 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
23 verbose node v12.16.1
24 verbose npm  v6.13.4
25 error code ELIFECYCLE
26 error errno 2
27 error motor-hat@1.0.0-semanticrelease build: `babel --copy-files --out-dir dist --ignore test/ lib`
27 error Exit status 2
28 error Failed at the motor-hat@1.0.0-semanticrelease build script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 2, true ]

Any ideas?

nrbrt commented

I manually copied the lib directory to the node_modules/motor-hat directory, together with the test directory and now npm run build completes successfully.
I tried running your the basic usage script and it showed me this:

/home/pi/node-projects/motor/node_modules/motor-hat/node_modules/i2c-bus/i2c-bus.js:423
    i2c.writeByteSync(peripheralSync(this, addr), cmd, byte);
        ^

Error: , Remote I/O error
    at Bus.writeByteSync (/home/pi/node-projects/motor/node_modules/motor-hat/node_modules/i2c-bus/i2c-bus.js:423:9)
    at setAllPWMSync (/home/pi/node-projects/motor/node_modules/motor-hat/dist/pwm.js:203:9)
    at Object.init (/home/pi/node-projects/motor/node_modules/motor-hat/dist/pwm.js:244:7)
    at Object.init (/home/pi/node-projects/motor/node_modules/motor-hat/dist/index.js:219:11)
    at Object.<anonymous> (/home/pi/node-projects/motor/test.js:1:75)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
  errno: 121,
  code: '',
  syscall: 'writeByteSync'
}

That might be ok, since I do not actually have a motor hat attached to my pi. As soon as I get this going, I will try and create a node-red implementation using your module.

nrbrt commented

awesome, thanks!

hi @nrbrt , just thought I'd give a quick update.

Sorry I haven't been able to cut the new release yet, but I'm working on it. Should be out by this weekend for sure.

Cheers!

@nrbrt , I've just published v2.0.10 of motor-hat, which should solve your initial problem. If you install directly from npm now it should work for you (as long as you have the motor hat connected).

I'll close this issue for now, feel free to reopen if you're still having problems with this.

Cheers

Pepe