thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
385 stars 48 forks source link

Cannot run on Node.js #136

Closed raymundovr closed 1 year ago

raymundovr commented 1 year ago

Hi 👋

I am following the Node.js tutorial found here https://developers.thegreenwebfoundation.org/co2js/tutorials/getting-started-node/

Unfortunately I cannot get to run the code:

❯ node index.js
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module './data/average-intensities-2021.min.js'
Require stack:
- /Users/r/Experimentos/co2js/node_modules/@tgwf/co2/dist/cjs/index-node.js
[...]

I can notice that such file average-intensities-2021.min.js does not exist

/Users/r/Experimentos/co2js/node_modules/@tgwf/co2/dist/cjs/data
.rw-r--r-- 4.7k r 20 Apr 07:04 average-intensities.min.js
.rw-r--r-- 6.1k r 20 Apr 07:04 average-intensities.min.js.map
.rw-r--r-- 4.6k r 20 Apr 07:04 marginal-intensities-2021.min.js
.rw-r--r-- 6.5k r 20 Apr 07:04 marginal-intensities-2021.min.js.map

I guess that the intendend file is average-intensities.min.js.

fershad commented 1 year ago

This is fix in release 0.13.1 Thank you for spotting this.

raymundovr commented 1 year ago

@fershad thanks for the quick reply!