Module not found: Can't resolve '@daml.js/..' in 'ex-bond-issuance-master\ui-js\src\pages\issuerRole'

Hey, DAMLer’s!

I am working on updating our demo and using daml codegen js for the first time. I’m definitely glad @cocreature put me on to it, it’s a really nifty tool.

However, I’m having a bit of trouble with it.

Using ex-bond-issuance as a baseline, I updated the DAML model to include our proprietary product - let’s call it OptimisProduct (including scenarios, scripts, triggers, etc.).

Once I did this, I rebuilt the bond-issuance.dar file and then ran daml codegen js. In the @daml.js folder I can see the @daml.js/bond-issuance-2.0.0/lib/DA/RefApps/Bond/OptimisProduct is generated. I cross-checked the code against the equivalent for FixedRateBond base case example and the codegen appears to have worked.

However, when I run yarn start I get the following error:

```
./src/pages/issuerRole/IssuerRole.jsModule not found: Can't resolve '@daml.js/bond-issuance-2.0.0/lib/DA/RefApps/Bond/OptimisProduct' in '...\ex-bond-issuance-master\ui-js\src\pages\issuerRole'
```

I usually see similar errors when I misspelled something, or deleted a file because I’m not using it anymore. I can see that the folder exists by clicking through the above path, but when I try to type out in visual studio my linter doesn’t pick it up as existing.

The only error I am getting in Visual Studio is the below:

Has anyone experienced an error like this when using daml codegen js? Could it be related to the error in the tsconfig.json file?

1 Like

Did you run yarn install --force from the ui directory after running daml codegen js?

2 Likes

Thanks, @cocreature . That worked.

I had done yarn install but it said everything was up to date.

What exactly is being updated or what was failing to be updated when I didn’t include --force?

It sounds like updating the daml is a three step exercise when using codegen in your ui:

  1. update .dar file
  2. re-run codegen
  3. run yarn install --force
1 Like

Yes the 3 steps are correct. Note that npm makes this a bit easier than yarn. Recent versions of the Getting Started Guide walk you through the NPM workflow.

As for what yarn install --force does: If you look at your package.json you can see that the generated code is referenced via a file: URI. Yarn does not pick up changes to such dependencies itself by default. yarn install --force will circumvent any caching and force a reinstall of that dependency. There are a few nicer solutions, e.g., yarn link but those have their own issues (symlinks don’t work as a non-admin on Windows by default) so we fall back to the lowest common denominator.

2 Likes