librenews on Nostr: I've set up a node project - Installed NDK - Looks fine on the server side. Can ...
I've set up a node project
- Installed NDK
- Looks fine on the server side. Can interact with relays etc.
- I installed webpack and the config is pretty basic
const path = require('path');
module.exports = {
target: 'web',
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
};
I have an entry file like this:
import NDK, { NDKNip07Signer, NDKEvent } from "@nostr-dev-kit/ndk";
- npx webpack successfully creates the bundle (I see refs to NDK in the bundle)
- In a web page I see the bundle being served successfully
- When I try to instantiate in the browser, the console reads :
Uncaught ReferenceError: NDK is not defined
I know it's my setup, not the NDK, but I don't work with JS like this often.
#nostrdev #asknostr
Published at
2023-10-03 13:47:21Event JSON
{
"id": "59ce06179c6341de84d8443dde2a897d56e770d89f3a56d0a514046c6d74b95f",
"pubkey": "66fdcf7c587d0e5dc61348571b53b50d7a8e3d7534a960f0224c8aa2a52e2912",
"created_at": 1696333641,
"kind": 1,
"tags": [
[
"t",
"nostrdev"
],
[
"t",
"asknostr"
]
],
"content": "I've set up a node project\n- Installed NDK\n- Looks fine on the server side. Can interact with relays etc.\n- I installed webpack and the config is pretty basic\n\nconst path = require('path');\n\nmodule.exports = {\n target: 'web',\n mode: 'production',\n entry: './src/index.js',\n output: {\n path: path.resolve(__dirname, 'dist'),\n filename: 'bundle.js'\n }\n};\n\nI have an entry file like this:\n\nimport NDK, { NDKNip07Signer, NDKEvent } from \"@nostr-dev-kit/ndk\";\n\n- npx webpack successfully creates the bundle (I see refs to NDK in the bundle)\n\n- In a web page I see the bundle being served successfully\n\n- When I try to instantiate in the browser, the console reads :\n\nUncaught ReferenceError: NDK is not defined\n\nI know it's my setup, not the NDK, but I don't work with JS like this often. \n\n#nostrdev #asknostr",
"sig": "27f03b03b9cadea4dcf054e3bb507b54b1ae2199de0d8b19e2576dd21aac007f98c8e31d5db915f04fb2f11492ca21519be984d13eef0d2f3ee767e2cdc9783f"
}