npwd
npwd copied to clipboard
Support: use server export (JS) in custom app
Development Issue
Unsure
Phone Version
master
Issue Description
I started rewriting an npwd's working app server.lua
to server.ts
. I don't know what I miss to be able to use onMessage
export (see https://projecterror.dev/docs/npwd/api/server-exports/ the Lua and JS code are almost the same).
I also read the FAQ (https://projecterror.dev/docs/npwd/faq/#errors) and have useResourceIntegration
set to true.
As on the server-exports page I don't have much code, but when I hit F12 on "exports" (in VS Code) it browses to @citizenfx/server
so what do I miss to install or configure?
import { oxmysql as MySQL } from '@overextended/oxmysql';
import { OnMessageExportCtx } from '@npwd/types';
const ESX = exports['es_extended'].getSharedObject();
console.log('Server started.');
exports.npwd.onMessage(value.num, (ctx: OnMessageExportCtx) => {
console.log(ctx);
}));
Thanks a lot.
Issue Reproduction
- Setup sample app from template
- Install "@npwd/types" package (
npm install --save-dev
) - update
server.ts
code as described - compile my app
- run FxServer that loads the app and logs Error: No such export onMessage in resource npwd
Evidence
No response