Open TheSman122333 opened 4 months ago
@Notplayingallday383
Did you run npm i
?
You need to install the dependencies first in order to use terbium
Yes, I still get the error.
index.mjs
import { Server } from "@tomphttp/bare-server-node";
^^^^^^
SyntaxError: Named export 'Server' not found. The requested module '@tomphttp/bare-server-node' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@tomphttp/bare-server-node';
const { Server } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
Node.js v18.12.1
If your using the latest version which includes the latest bare version server was deprecated and replaced with createBareServer
I think it is a newer version
"@tomphttp/bare-server-node": "^2.0.1",
@Notplayingallday383
btw this is a very old fork, probably even before v1.41, but maybe v.1.41
ok so since ur using a newer version of Bare, the "server" function has been deprecated in place for { createBareServer } so in your backend just change the line: import Server from 'bare-server-node';
to: import { createBareServer } from 'bare-server-node'
that should work
I changed the code to this:
import { createBareServer } from 'bare-server-node';
import http from 'http';
import nodeStatic from 'node-static';
const bare = new createBareServer('/bare/', '');
const serve = new nodeStatic.Server('static/');
const server = http.createServer();
server.on('request', (request, response) => {
if (bare.route_request(request, response)) return true;
serve.serve(request, response);
});
server.on('upgrade', (req, socket, head) => {
if(bare.route_upgrade(req, socket, head))return;
socket.end();
});
server.listen(process.env.PORT || 6969);
and nothing is happening, the ouput console is empty.
@Notplayingallday383
Ok that means it should be working cus that code doesn’t have a console.log that states the server is ready so try visiting http://localhost:6969 and seeing if it worked
nevermind, i get this error
init.logErrors ??= false;
^
TypeError: Cannot create property 'logErrors' on string ''
at new createBareServer (/home/runner/teemingarcticports/node_modules/bare-server-node/dist/createServer.js:42:20)
at file:///home/runner/teemingarcticports/index.mjs:6:15
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
Node.js v18.12.1
on this line
const bare = new createBareServer('/bare/', '');
@Notplayingallday383
on this line
const bare = new createBareServer('/bare/', '');
@Notplayingallday383
Sorry I forgot to respond but the ,'' I dont think works. So I would suggest changing it to: const bare = createBareServer('/bare/');
import { createBareServer } from 'bare-server-node'; import http from 'http'; import nodeStatic from 'node-static';
const bare = createBareServer('/bare/'); const serve = new nodeStatic.Server('static/');
const server = http.createServer();
server.on('request', (request, response) => { if (bare.route_request(request, response)) return true; serve.serve(request, response); });
server.on('upgrade', (req, socket, head) => { if(bare.route_upgrade(req, socket, head))return; socket.end(); });
server.listen(process.env.PORT || 6969); its giving
file:///home/runner/teemingarcticports/index.mjs:12 if (bare.route_request(request, response)) return true; ^
TypeError: bare.route_request is not a function
at Server.
Node.js v18.12.1
Alright since that isn’t working just copy and paste the new backend code instead of the really old one which can be found: https://github.com/TerbiumOS/webOS/blob/main/index.js
/home/runner/teemingarcticports/index.js:1 import { createBareServer } from "@tomphttp/bare-server-node"; ^^^^^^
SyntaxError: Cannot use import statement outside a module Hint: hit control+c anytime to enter REPL.
new code
Copy package.json too
I'm sorry, I was locked out of my github acc for a while, can we meet on discord or something and debug it? It works but I get this error Error: ENOENT: no such file or directory, stat '/home/runner/teemingarcticports/static/sw/hvtrs8/-ymuvu`e,cmm'
I saw someone had an error and it was with service workers, but I want to be able to customize my apps not just have the defaults, if it is possible to change it and bypass repls blocking, I will try to use the newest version.
I'm sorry, I was locked out of my github acc for a while, can we meet on discord or something and debug it? It works but I get this error Error: ENOENT: no such file or directory, stat '/home/runner/teemingarcticports/static/sw/hvtrs8/-ymuvu`e,cmm'
Yeah sure
const bare = new Server('/bare/', ''); ^
TypeError: Server is not a constructor at file:///home/runner/TeemingArcticPorts/index.mjs:6:15 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
OS version 1.41 I think, I made a fork of terbium a looong time ago, and I recovered it. Using Opera GX/Chrome
The issue is that there is no output in the repls saying that server isnt a constructor, but in 1.41, and 1.42 it uses the code that gives the error
this code: import Server from 'bare-server-node'; import http from 'http'; import nodeStatic from 'node-static';
const bare = new Server('/bare/', ''); const serve = new nodeStatic.Server('static/');
const server = http.createServer();
server.on('request', (request, response) => { if (bare.route_request(request, response)) return true; serve.serve(request, response); });
server.on('upgrade', (req, socket, head) => { if(bare.route_upgrade(req, socket, head))return; socket.end(); });
server.listen(process.env.PORT || 6969);