# Adapting the EIA Example

**URL:** <https://talk.observablehq.com/t/adapting-the-eia-example/8863>\
**Category:** Help\
**Created:** [February 27, 2024, 3:55pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863 "2024-02-27T15:55:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FUenal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fuenal/32/8542_2.png) [@FUenal](https://talk.observablehq.com/u/FUenal)\
**Post date:** [February 27, 2024, 3:55pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/1 "2024-02-27T15:55:14Z")

</div>

Hi all, I am new to Observable and would like to start learning by adapting the US Electricity Grid example ([U.S. electricity grid](https://observablehq.com/framework/examples/eia/)). I could not find a tutorial on this so, here we go: What is the best way to set up this example? I initialized an empty observable project folder and copied the files from the github repo ([framework/examples/eia at main · observablehq/framework · GitHub](https://github.com/observablehq/framework/tree/main/examples/eia)) into said folder but receive errors when running npm run dev.

‘Error [ERR\_MODULE\_NOT\_FOUND]: Cannot find package ‘dotenv’ imported from /Users/Fatih/Documents/data\_science/DS Portfolio/Observable/energy\_dashboard/docs/data/eia-ba-hourly.csv.js’

In python (where I code) I would just install these packages. Dont know what to do here.

Any advice much appreciated!

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [February 27, 2024, 4:06pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/2 "2024-02-27T16:06:49Z")

</div>

It should work if you also copy package.json, which lists the dependencies that we want npm to install, like dotenv on line 11:

> <https://github.com/observablehq/framework/blob/main/examples/eia/package.json#L11>

---

<div class="post-metadata">

**Author:** ![FUenal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fuenal/32/8542_2.png) [@FUenal](https://talk.observablehq.com/u/FUenal)\
**Post date:** [February 27, 2024, 4:12pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/3 "2024-02-27T16:12:36Z")

</div>

Thanks, @Fil ! I have copied the package.json file but am receiving error messages. When I run npm install, I get the following error:

Fatih@MacBook-Air energy\_dashboard % npm install  
npm ERR! code EUNSUPPORTEDPROTOCOL  
npm ERR! Unsupported URL Type “link:”: link:…/…

npm ERR! A complete log of this run can be found in:

Sorry, I am a blood newbie with npm…  
My npm --version (10.1.0)

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [February 27, 2024, 4:31pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/4 "2024-02-27T16:31:33Z")

</div>

Ah… now this error is because we’re building the examples from within the framework repo, using code from that repo (that is what the “link:” reference does).

For now you can replace that line by

`"@observablehq/framework": "1"`

but we’ll need to find a way to make this easier.

---

<div class="post-metadata">

**Author:** ![FUenal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fuenal/32/8542_2.png) [@FUenal](https://talk.observablehq.com/u/FUenal)\
**Post date:** [February 27, 2024, 5:24pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/5 "2024-02-27T17:24:55Z")

</div>

Thanks, for getting back to me. For absolute beginners like me, a step-by-step guide to get the examples running would be great!  
I am still receiving the same error message as before

Error [ERR\_MODULE\_NOT\_FOUND]: Cannot find package dotenv

and other packages (d3) as well.

I tried both a new init with and without examples, and copied the files from the example repo (the entire content of the eia folder, including the package.json folder) but no success.

I would love to add the observable framework to my stack but need more beginner-friendly instructions. Maybe there is a tutorial that works with the examples in the main repo? Or somebody here could walk me through? Thanks for your time and effort!

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [February 28, 2024, 8:38am UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/6 "2024-02-28T08:38:30Z")

</div>

Did you run `npm install` after you edited `package.json`? This should have installed dotenv and the rest.

I agree that these examples are difficult to run independently. To be fair they were meant to show what’s possible, not as starter projects: for this we have templates. But, we’ll definitely have to make them more usable.

---

<div class="post-metadata">

**Author:** ![FUenal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fuenal/32/8542_2.png) [@FUenal](https://talk.observablehq.com/u/FUenal)\
**Post date:** [February 28, 2024, 8:49am UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/7 "2024-02-28T08:49:24Z")

</div>

Jep, I did. After `npm install`, running `npm run dev` does not work anymore (see screenshot)

It would be helpful to have a more beginner-friendly guideline for adapting the existing examples in the repo, I think, maybe I am not the only one.

I will put this on ice for now until then and get back to working with streamlit, dash and co.

Thanks for your quick response and looking forward to getting back to this amazing framework!

 ![Screenshot 2024-02-28 at 09.45.40](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/f/f4b268a17c08868ec515c6d7a0c6f524f1034b59.png)

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [February 28, 2024, 9:25am UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/8 "2024-02-28T09:25:53Z")

</div>

probably need to remove the `postinstall` step too, and reinstall (maybe remove node\_modules/ first)? you’re getting closer!

It worked for me when I changed package.json to the following, then ran `npm install && npm run dev`

```auto
{
  "type": "module",
  "scripts": {
    "dev": "observable preview",
    "build": "rm -rf dist && observable build"
  },
  "dependencies": {
    "@observablehq/framework": "1",
    "d3": "^7.8.5",
    "dotenv": "^16.3.1",
    "topojson-client": "^3.1.0",
    "topojson-simplify": "^3.0.3"
  },
  "engines": {
    "node": ">=20.6"
  }
}

```

---

<div class="post-metadata">

**Author:** ![FUenal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fuenal/32/8542_2.png) [@FUenal](https://talk.observablehq.com/u/FUenal)\
**Post date:** [February 28, 2024, 12:12pm UTC](https://talk.observablehq.com/t/adapting-the-eia-example/8863/9 "2024-02-28T12:12:23Z")

</div>

Brilliant, it runs! Did not remove node\_modules/

Thanks a bunch for the great support! Observable Framework beats Streamlit and Dash by far! Happy to add this to my stack and continue to learn. Cheers!
