The CLI (v2, beta) up-and-running challenge/documentation

Hey,
Is this issue related to version incompatibility!

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol ‘c:’
at new NodeError (node:internal/errors:400:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1055:11)
at defaultResolve (node:internal/modules/esm/resolve:1135:3)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:842:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ESMLoader.import (node:internal/modules/esm/loader:525:22)
at importModuleDynamically (node:internal/modules/esm/translators:110:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at loadActualModule (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/runtime/dist/index.js:246:7) {
code: ‘ERR_UNSUPPORTED_ESM_URL_SCHEME’
}

Node.js v18.13.0

openfn --version
0.0.25

Maybe! What OS and node version are you using? And what command did you pass to the CLI to get it to print that error?

Here is the full stackstrace:

C:\Users\Admin\OpenFnProjects\OpenFnCLI>openfn hello.js -ia http
[CLI] √ Installing packages…
[CLI] √ Installation complete in 5.534s
[CLI] :bangbang: Error loading state from ./state.json
[CLI] :bangbang: [Error: ENOENT: no such file or directory, open ‘C:\Users\Admin\OpenFnProjects\OpenFnCLI\state.json’] {
errno: -4058,
code: ‘ENOENT’,
syscall: ‘open’,
path: ‘C:\Users\Admin\OpenFnProjects\OpenFnCLI\state.json’
}
[CLI] :bangbang: Using default state { data: {}, configuration: {}
[CLI] × Failed to load adaptor typedefs from path C:\tmp\openfn\repo\node_modules@openfn\language-http_4.2.3
[CLI] × Error: Failed getting file at: C:\tmp\openfn\repo\node_modules@openfn\language-http_4.2.3/package.json got: 400 Bad Request
at fetchFile (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/describe-package/dist/index.js:380:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async preloadAdaptorExports (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/compiler/dist/index.js:284:20)
at async loadTransformOptions (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:235:19)
at async compile_default (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:193:30)
at async executeHandler (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:389:16)
[CLI] √ Compiled job from hello.js
node:internal/errors:491
ErrorCaptureStackTrace(err);
^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol ‘c:’
at new NodeError (node:internal/errors:400:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1055:11)
at defaultResolve (node:internal/modules/esm/resolve:1135:3)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:842:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ESMLoader.import (node:internal/modules/esm/loader:525:22)
at importModuleDynamically (node:internal/modules/esm/translators:110:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at loadActualModule (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/runtime/dist/index.js:246:7) {
code: ‘ERR_UNSUPPORTED_ESM_URL_SCHEME’
}

Node.js v18.13.0

openfn hello.js -ia http

Almost similar error is shown on both Node.js v18.13.0 and v18.0.0

See the following information to get details of the environment. I am using Windows 10
openfn test
[CLI] i Versions:
▸ Node.js 18.0.0
▸ cli 0.0.25
▸ runtime 0.0.15
▸ compiler 0.0.22
[CLI] i Running test job…
[CLI] :bangbang: No state detected: pass -S to provide some state
[CLI] √ Compiled job from const fn = () => state => state * 2; fn()

[CLI] i Compiled job:
const fn = () => state => state * 2;
export default [fn()];

[CLI] i Running job…
[R/T] √ Operation 1 complete in 0ms
[CLI] √ Result: 42

Interesting! And what’s in that hello.js file that causes the error? (And… sorry for the simple questions… is that the correct path or do you need some sort of ./hello.js ? Sorry, I’m no good at the Windows command line.)

Contents of hello.js

fn((state) => { console.log(“Hello World!”); return state; });

C:\Users\Admin\OpenFnProjects\OpenFnCLI

PS C:\Users\Admin\OpenFnProjects\OpenFnCLI> openfn .\hello.js -ia http
[CLI] :heavy_check_mark: Installing packages…
[CLI] :heavy_check_mark: Installation complete in 13.191s
[CLI] :warning: Error loading state from ./state.json
[CLI] :warning: [Error: ENOENT: no such file or directory, open ‘C:\Users\Admin\OpenFnProjects\OpenFnCLI\state.json’] {
errno: -4058,
code: ‘ENOENT’,
syscall: ‘open’,
path: ‘C:\Users\Admin\OpenFnProjects\OpenFnCLI\state.json’
}
[CLI] :warning: Using default state { data: {}, configuration: {}
[CLI] ✘ Failed to load adaptor typedefs from path C:\tmp\openfn\repo\node_modules@openfn\language-http_4.2.3
[CLI] ✘ Error: Failed getting file at: C:\tmp\openfn\repo\node_modules@openfn\language-http_4.2.3/package.json got: 400 Bad Request at fetchFile (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/describe-package/dist/index.js:380:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async preloadAdaptorExports (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/compiler/dist/index.js:284:20)
at async loadTransformOptions (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:235:19)
at async compile_default (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:193:30)
at async executeHandler (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/dist/process/runner.js:389:16)
[CLI] :heavy_check_mark: Compiled job from .\hello.js
node:internal/errors:491
ErrorCaptureStackTrace(err);
^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows,
absolute paths must be valid file:// URLs. Received protocol ‘c:’
at new NodeError (node:internal/errors:400:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1055:11)
at defaultResolve (node:internal/modules/esm/resolve:1135:3)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:842:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ESMLoader.import (node:internal/modules/esm/loader:525:22)
at importModuleDynamically (node:internal/modules/esm/translators:110:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at loadActualModule (file:///C:/Users/Admin/AppData/Roaming/npm/node_modules/@openfn/cli/node_modules/@openfn/runtime/dist/index.js:246:7) {
code: ‘ERR_UNSUPPORTED_ESM_URL_SCHEME’
}

Node.js v18.13.0
PS C:\Users\Admin\OpenFnProjects\OpenFnCLI>

Can you try to run the job with the .\
Eg: openfn hello.js -ia http

The following command is what is generating the error message:

PS C:\Users\Admin\OpenFnProjects\OpenFnCLI> openfn .\hello.js -ia http

Apologies @haftamuk I actually meant without .\
Please run the job like this openfn hello.js -ia http

Hey @haftamuk , I’ve run into the same issue. Sit tight while we come up with a Windows workaround. Back in a flash. (Right now thinking about building adaptors locally for windows and passing the path, rather than using that “auto-install” feature in the CLI.)

Exactly! That seems an alternative. Any manuals I can refer for that to try myself?

Just testing now but local builds on Windows will probably have path related issues—all of our testing has been on Linux… ubuntu and mac mostly.

@haftamuk , of the group that was meant to do the challenge, what percent do you think are using Windows? Wondering if we should delay the training by a couple of days. If you’ve run into this Windows bug now and they’re also using Windows, I think it’s safe to assume that they haven’t completed the pre-requisites. What do you think? Feel free to give me a buzz if you’d rather chat on the phone.

Thanks and speak soon!

Taylor

Hey @haftamuk and @mtuchi , update:

@jclark has just fixed this :raised_hands: and you can update to v0.0.26 for windows support. We should still touch base tomorrow morning about whether or not you’d like to go forward with the training… I think it would be much better to ensure that everyone had completed (and provided feedback/edits to) the getting-started/developer-challenge. Thoughts?

1 Like

Cool. Its working!
Thanks for the prompt response on this one.
Issue Resolved.

1 Like

hello openFn,
once I have completed the mapping of incoming source data(.json) file to DHIS2 destination system how I can sync (post) the mapped formatted .json file. I know already have create method in DHIS2 built in adaptors that accepts the resource, data with optional parameters and callback function. however my question is can I create another state.json file to store the data and credentials for DHIS2. thanks…

Hello Daniel,

Yes, you need to create another state.json file with the DHIS2 credentials
Then use the function provided in the DHIS2 adaptor to create a trackedEntityInstance see documentation below
https://docs.openfn.org/adaptors/packages/dhis2-docs#createresourcetype-data-options-callback–operation

Let me know if you have any questions

Best,
Mtuchi

Hello mtuchi,
thanx so much for you ur attention and quick response, how i can win up the data from source system into dhis2 data key and how i can assign the path of array during using of “each” method.