lpgera / dirigera-web

A progressive web app for controlling Dirigera smart home devices.
MIT License
11 stars 0 forks source link

run build error #1347

Open aldodemi opened 1 month ago

aldodemi commented 1 month ago

Error starting from scratch, mode "Running with Node.js natively":

npm run build

build npm run build -ws

build swc src -d dist --strip-leading-paths

Bus error (core dumped) npm error Lifecycle script build failed with error: npm error Error: command failed npm error in workspace: backend npm error at location: /home/domoticz/dirigera-web/backend

lpgera commented 1 month ago

I've never seen this "Bus error" output from swc. What version of node and npm do you have installed?

aldodemi commented 1 month ago

domoticz@ns1server:~/dirigera-web$ nvm use node Now using node v22.2.0 (npm v10.7.0)


domoticz@ns1server:~/dirigera-web$npm install npm warn deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead

prepare husky

added 1743 packages, and audited 1746 packages in 17s

311 packages are looking for funding run npm fund for details

found 0 vulnerabilities domoticz@ns1server:~/dirigera-web$ npm run build

build npm run build -ws

build swc src -d dist --strip-leading-paths

Successfully compiled: 18 files with swc (134.45ms)

build vite build

vite v5.2.11 building for production... ✓ 1734 modules transformed. build/registerSW.js 0.14 kB build/manifest.webmanifest 0.53 kB build/index.html 0.79 kB │ gzip: 0.45 kB build/assets/index-Cm_1FYRq.css 2.97 kB │ gzip: 1.19 kB build/assets/index-DfVdi6X3.js 1,024.26 kB │ gzip: 324.28 kB

(!) Some chunks are larger than 500 kB after minification. Consider:

PWA v0.20.0 mode generateSW precache 15 entries (1079.92 KiB) files generated build/sw.js build/workbox-464e6d59.js

lpgera commented 1 month ago

This looks like you succeeded with the build. 🙂 What was the solution?

aldodemi commented 1 month ago

this is after the build:

domoticz@ns2server:~/dirigera-web$ npm start

start npm run start -w backend

start node dist/index.js

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

Error: Cannot find module '/home/domoticz/dirigera-web/backend/dist/index.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1224:15) at Module._load (node:internal/modules/cjs/loader:1050:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:168:12) at node:internal/main/run_main_module:30:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }

Node.js v22.1.0 npm error Lifecycle script start failed with error: npm error Error: command failed npm error in workspace: backend npm error at location: /home/domoticz/dirigera-web/backend domoticz@ns2server:~/dirigera-web$

aldodemi commented 1 month ago

Start again from scratch, Compile ok. Run error:

domoticz@ns2server:~/dirigera-web$ npm start

start npm run start -w backend

start node dist/index.js

/home/domoticz/dirigera-web/node_modules/@lpgera/ts-env/dist/src/orThrow.js:7 throw new Error(Couldn't read ${type} value from process.env.${key}); ^

Error: Couldn't read string value from process.env.JWT_SECRET at /home/domoticz/dirigera-web/node_modules/@lpgera/ts-env/dist/src/orThrow.js:7:19 at exports.default [as stringOrThrow] (/home/domoticz/dirigera-web/node_modules/@lpgera/ts-env/dist/src/stringOrThrow.js:8:78) at Object. (/home/domoticz/dirigera-web/backend/dist/jwt.js:26:35) at Module._compile (node:internal/modules/cjs/loader:1434:14) at Module._extensions..js (node:internal/modules/cjs/loader:1518:10) at Module.load (node:internal/modules/cjs/loader:1249:32) at Module._load (node:internal/modules/cjs/loader:1065:12) at Module.require (node:internal/modules/cjs/loader:1271:19) at require (node:internal/modules/helpers:123:16) at Object. (/home/domoticz/dirigera-web/backend/dist/graphql/definitions/auth.js:21:14)

Node.js v22.2.0 npm error Lifecycle script start failed with error: npm error Error: command failed npm error in workspace: backend npm error at location: /home/domoticz/dirigera-web/backend

My .env file is (apart from ACCESS_TOKEN the rest is "real"):

GATEWAY_IP=172.16.3.7 ACCESS_TOKEN="MYACCESSTOKEN" JWT_SECRET=your-random-secret-key JWT_EXPIRY=7 days PASSWORD=password PORT=4000

lpgera commented 1 month ago

I'm not using this project without Docker nowadays, so it's likely that the environment variable reading is broken.

Could you try to start it with node --env-file=.env backend/dist/index.js as a workaround?

aldodemi commented 1 month ago

This way it works