Need help with getting started

Hello DAML community,

My name is Shyam Suchak and I am interested to explore the space and learning more about coding with DAML.

As any newbie will do, I went to Daml documentation > Getting started section and installed sdk + npm on my machine.

As per the guide Getting Started with Daml — Daml SDK 1.17.1 documentation when I hit npm start, I am getting the below error. Can you please help me out to resolve the issue.

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:503:5
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:358:12
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\react-scripts\scripts\start.js:19
throw err;
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:417:16)
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:452:10
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\webpack\lib\NormalModule.js:323:13
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at D:\SourceCode\GitHub\DAML\daml-first-project\create-daml-app\ui\node_modules\babel-loader\lib\index.js:59:103 {
opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],
library: ‘digital envelope routines’,
reason: ‘unsupported’,
code: ‘ERR_OSSL_EVP_UNSUPPORTED’
}

1 Like

I’m not an expert here, but a quick search on the Internet seems to suggest that you might be using Node.js 17, which uses OpenSSL 3 by default, which seems to possibly be breaking things here and there (nodejs 17: digital envelope routines::unsupported · Issue #14532 · webpack/webpack · GitHub).

Can you try and see if running NODE_OPTIONS=--openssl-legacy-provider npm start works for you?

2 Likes

Thanks, Stefan your solution worked.

For windows

set NODE_OPTIONS=–openssl-legacy-provider

npm start

Now I am getting another error

Request with path /v1/fetch proxied from host localhost:3000 to host http://localhost:7575
[HPM] Error occurred while proxying request localhost:3000/v1/fetch to http://localhost:7575/ [ECONNREFUSED] (Errors | Node.js v17.0.1 Documentation)

ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host

How to triage this issue now, it seems like openssl incompatibility must be playing a part here.

Please help

Hi @ShyamSuchakATP,

ECONNREFUSED usually means that there is no program listening to the given port. In this case, this may indicate that you have not started the JSON API server. In the case of the create-daml-app template, before you can run npm start, you need to have daml start running.

Otherwise, you’re essentially running your frontend server with no backend server, which does not work.

2 Likes

Hi @ShyamSuchakATP

Here is an excellent set of learning materials, which might be helpful for you.

2 key steps are always:

  • daml build
  • daml start

If you can get any Daml app (.DAR) built and running without errors that is a great start.

Keep in touch :+1:t2:

Hi, I was getting the same error as the one in the post. and did set NODE_OPTIONS …
However, now when I run “npm start” - I get the following error:
C:\Program Files\nodejs\node.exe: -openssl-legacy-provider is not allowed in NODE_OPTIONS

Here are my version specs:
daml version: 2.4.0 (project SDK version from daml.yaml)
node -v: v19.2.0
java -version:
openjdk version “17.0.5” 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

You need to start the option with two dashes:

--openssl-legacy-provider

not

-openssl-legacy-provider
2 Likes

This worked! It launched the daml App. However, now I have a new issue:
When I try to enter “alice” or “bob” to log in, I get a:
Failed to login as ‘alice’
SyntaxError:Unexpected token ‘E’, “Error occu”… is not valid JSON

Is it because I have a version 19 for the node.js or is it something else?

@dzubarchuk
I don’t think this error is related to the version of Node you’re using. This error could indicate that your Node application cannot communicate with the HTTP JSON API server. E.g. it could be that the HTTP JSON API server, that allows your Node application to submit commands to the ledger, is not running. What Daml app are you launching and how are you launching it?

I believe this is indeed related to Node 19. Here is what I think is happening:

Node 19 (as well as the latest versions of Node 18, actually) now resolves localhost to ::1, whereas the JSON API only binds to 127.0.0.1 (IPv6 v. IPv4). So the Node development server started by npm start tries to connect to ::1, gets a “connection refused”, returns that to our Daml code (Error occured when trying to connect: connection refused), which is expecting JSON and thus fails to parse that as JSON on the first character as E is not valid there (for valid JSON it can only be one of ", [, {, t, f, n, or a digit).

If that is indeed your issue, the easiest fix is to replace all occurrences of localhost with 127.0.0.1 manually. There is one occurrence in ui/package.json and one in ui/src/setupProxy.js.

This fix will be part of 2.5.0.

Yea it was related to the node version. Thank you so much for clearing that up for me!