Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express + rpi-led-matrix -> cannot find ../encodings #28

Closed
BoldBigflank opened this issue Mar 16, 2022 · 1 comment
Closed

Express + rpi-led-matrix -> cannot find ../encodings #28

BoldBigflank opened this issue Mar 16, 2022 · 1 comment

Comments

@BoldBigflank
Copy link

BoldBigflank commented Mar 16, 2022

After installing express@4.17.3 and rpi-led-matrix@1.11.1 I try to run an express server with the following code:

import { LedMatrix } from 'rpi-led-matrix';
import express, { Request, Response } from "express"

const matrix = new LedMatrix(
  LedMatrix.defaultMatrixOptions(),
  LedMatrix.defaultRuntimeOptions()
);

// Expressjs
const app = express()
app.use(express.json())
const PORT = process.env.port || 5555
let running = false

app.post('/move', (req: Request, res: Response) => {
    console.log('/move', req.body)
    res.send("OK")
})

// Get it started
matrix.sync();

app.listen(PORT, () => {
  console.log(`⚡ Server running at https://localhost:${PORT}`)
})

When I send a POST /move with a basic json body I am met with the following error:

Error: Cannot find module '../encodings'
Require stack:
- /home/alex/battlesnake-board/node_modules/raw-body/node_modules/iconv-lite/lib/index.js
- /home/alex/battlesnake-board/node_modules/raw-body/index.js
- /home/alex/battlesnake-board/node_modules/body-parser/lib/read.js
- /home/alex/battlesnake-board/node_modules/body-parser/lib/types/json.js
- /home/alex/battlesnake-board/node_modules/body-parser/index.js
- /home/alex/battlesnake-board/node_modules/express/lib/express.js
- /home/alex/battlesnake-board/node_modules/express/index.js
- /home/alex/battlesnake-board/board.ts
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/home/alex/battlesnake-board/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.getCodec (/home/alex/battlesnake-board/node_modules/raw-body/node_modules/iconv-lite/lib/index.js:65:27)
    at Object.getDecoder (/home/alex/battlesnake-board/node_modules/raw-body/node_modules/iconv-lite/lib/index.js:127:23)
    at getDecoder (/home/alex/battlesnake-board/node_modules/raw-body/index.js:45:18)
    at readStream (/home/alex/battlesnake-board/node_modules/raw-body/index.js:180:15)
    at getRawBody (/home/alex/battlesnake-board/node_modules/raw-body/index.js:108:12)

There's one other Issue with this error but I can't seem to get it fixed. I think that the issue lies with the fact that I need to use sudo to have access to the gpio, but then I don't have access to node_modules when it's time to lazy load it. How can I reconcile this?

@alexeden
Copy link
Owner

alexeden commented Apr 4, 2022

Hi @BoldBigflank sorry for the delayed response. Have you had any success with this?
I'm going to go ahead and close the issue because I don't think a solution is within scope/capabilities of this library. (they're just bindings, after all) And, to be honest, I'm still baffled by how permissions and privileges work as they relate to the hardware access needed by the underlying hzeller library on a Raspberry Pi. My best suggestions would be to keep investigating that other issue you linked to, or dig further into the permissions stuff I just mentioned. Good luck!

@alexeden alexeden closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants