pinax-network / substreams-sink-csv

Substreams Sink CSV
MIT License
1 stars 0 forks source link

pm2 issue ERR_REQUIRE_ESM #11

Closed DenisCarriere closed 6 months ago

DenisCarriere commented 6 months ago
0|substrea | Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/denis/.nvm/versions/node/v21.6.2/lib/node_modules/substreams-sink-csv/dist/bin/cli.js not supported.
0|substrea | Instead change the require of cli.js in null to a dynamic import() which is available in all CommonJS modules.
0|substrea |     at Object.<anonymous> (/Users/denis/.nvm/versions/node/v21.6.2/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) {
0|substrea |   code: 'ERR_REQUIRE_ESM'
0|substrea | }
DenisCarriere commented 6 months ago

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/denis/.nvm/versions/node/v21.6.2/lib/node_modules/substreams-sink-csv/dist/bin/cli.mjs not supported. 0|substrea | Instead change the require of /Users/denis/.nvm/versions/node/v21.6.2/lib/node_modules/substreams-sink-csv/dist/bin/cli.mjs to a dynamic import() which is available in all CommonJS modules.

DenisCarriere commented 6 months ago

Resolved with docs:

Using pm2

Install pm2

$ npm install -g pm2
$ npm install substreams-sink-csv

ecosystem.config.js

module.exports = {
    apps: [{
        name: "substreams-sink-csv",
        script: "./node_modules/substreams-sink-csv/dist/bin/cli.mjs",
        env: {
            SUBSTREAMS_API_KEY: '<your-api-key>',
            MANIFEST: 'https://github.com/streamingfast/substreams-eth-block-meta/releases/download/v0.5.1/substreams-eth-block-meta-v0.5.1.spkg',
            MODULE_NAME: 'graph_out',
            SUBSTREAMS_ENDPOINT: 'eth.substreams.pinax.network:443',
            FINAL_BLOCKS_ONLY: 'true',
            START_BLOCK: '2',
            SCHEMA: 'schema.example.sql',
        }
    }]
}

Start the process

$ pm2 start