dahlia / fedify

ActivityPub server framework in TypeScript
https://fedify.dev/
MIT License
327 stars 13 forks source link

issue with using this in ExpressJS .ts files #59

Closed redimongo closed 3 weeks ago

redimongo commented 4 weeks ago

I am not sure what I am doing wrong, but I followed the install process for NodeJS and I am getting this error.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/russellharrower/Node_Projects/podcast-performance/server/node_modules/@fedify/fedify/package.json

I am importing it like this

import { Federation, MemoryKvStore, Person } from "@fedify/fedify";

We use in our package manager.

  "scripts": {
    "start": "node dist/server.js",
    "build": "tscx --copyfiles"
  },
dahlia commented 4 weeks ago

Did you add "type": "module" to your package.json?

redimongo commented 4 weeks ago

Did you add "type": "module" to your package.json?

yes I did and that brought up other issues with

file:///Users/russellharrower/Node_Projects/podcast-performance/server/dist/server.js:25
Object.defineProperty(exports, "__esModule", { value: true });
                      ^

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/russellharrower/Node_Projects/podcast-performance/server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
dahlia commented 4 weeks ago

Since Fedify only supports ESM, your app should be in ESM too. I guess your bundler or tsc generates CJS files?

redimongo commented 3 weeks ago

Yeah, could not get it to work with my system, so I decided I'll have to recode my system to work with Deno.

So far the deno sample code works well - so thank you. The reason I am using this tool, is because I could not get the Accept to work when Follow request came in.