Package.json are not generated when running daml codegen

Hi guys,
I get this error when running npm install after running make build, here is my make file content:

build:
	daml build
	daml codegen js -o ui .daml/dist/*.dar
	daml damlc visual .daml/dist/*.dar --dot private-nft.dot
	cd ui && npm install
	cd ui && npm run build

I noticed that the package.json are not generated.

Is there anything need I to modify on my code? Thanks

Best regards,

1 Like

The codegen will generate a set of packages each with their own package.json. E.g., for create-daml-app the directory structure looks something like this (simplified)

daml.js
daml.js/cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7
daml.js/cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7/package.json
daml.js/733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a
daml.js/733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a/package.json
daml.js/76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f
daml.js/76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f/package.json
daml.js/7f251391d4950ccf51b9983ebd2ffe1823d49ce92b536cc4ea96c18b38e2ae28
daml.js/7f251391d4950ccf51b9983ebd2ffe1823d49ce92b536cc4ea96c18b38e2ae28/package.json
daml.js/create-daml-app-0.1.0
daml.js/create-daml-app-0.1.0/package.json

The codegen will not generate a top-level package.json for your own project. You have to define that yourself and reference the generated packages in the dependencies. You can see the one used for create-daml-app here daml/package.json.template at 2bdcb7b69fa6cb07b14e1f7a99391db822d8766b · digital-asset/daml · GitHub (replace PROJECT_NAME by your own project name and adjust file paths as needed).

3 Likes

Hi @cocreature
Thank you for replying. Yes I uderstand now, my test project was created without the create-daml-app as template which result into no package.json created on ui folder.

Solution was to create a package.json under folder where you output the codegen js. Another was use the create-daml-app as template and it was ready for you to use.

Awesome!

Thank you

1 Like