By “port locally” do you mean that you are trying to port code from Observable to a standalone JS file? Could you share links to gists with the full file(s)?
Here are some guesses based on the snippets you’ve provided. For the first one, .join is not a function makes me think that you might not be using a version of d3 with .join.
For the second one, as @severo has pointed out, you cannot use await at the top level of an ordinary JS file. You can try wrapping your code in an async function and then evaluating it like this:
async function loadData() {
// ...
const data = await d3.json('./data/graph.json');
const links = data.links.map(d => Object.create(d));
// ...
}
loadData().then(() => { /* do other stuff */ });