LHNCBC / lforms

See the project website at http://lhncbc.github.io/lforms/, or view the demo website at https://lhcforms.nlm.nih.gov/lhcforms.
Other
107 stars 56 forks source link

Error using run build #145

Closed DaniArj1980 closed 5 months ago

DaniArj1980 commented 8 months ago

Hi, From what I understand I have to follow this series of steps to be able to use the lforms package.

image

When running npm run build, I get the following error:

lforms@35.0.3 build:version C:\Curso\Angular\lforms node -e 'require("fs").writeFileSync("src/version.json", JSON.stringify({lformsVersion: require("./package.json").version}))'

'require(fs).writeFileSync(src/version.json, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token at new Script (vm.js:102:7) at createScript (vm.js:263:10) at Object.runInThisContext (vm.js:311:10) at internal/process/execution.js:77:19 at eval-wrapper:6:22 at evalScript (internal/process/execution.js:76:60) at internal/main/eval_string.js:23:3

I am using node js 20, I don't know if that is the reason. Could you help me?

Greetings, thank you

plynchnlm commented 8 months ago

We build lforms on Linux, so probably the issue is that there is something platform-specific in our build scripts. It looks like some issue with quotation marks. Anyway, are you trying to modify lforms? If you just want to use it, you can either you "npm install lforms" or download pre-built versions directly from https://lhcforms-static.nlm.nih.gov/lforms-versions/ (and note that there are zip files there, and that the latest version is currently 35.0.3).

DaniArj1980 commented 8 months ago

Thank you very much, our idea is to import functionalities to store, modify and send responses to questionnaires on a FHIR server, as well as display them on the frontend. Something similar to the Form Builder option in the demo. Would it be possible? By running "npm install lforms" and importing the component, we could use the functions described at http://lhncbc.github.io/lforms/

Greetings, thank you

plynchnlm commented 8 months ago

Yes, either by installing or downloading, or linking to the lforms-static website files above, you can use lforms without buliding it. However, "importing" it won't work. Just link to the files via script/link tags (as documented at http://lhncbc.github.io/lforms/#installation). For a simple example, see https://jsfiddle.net/lforms/8f754jhy/44/ .

DaniArj1980 commented 8 months ago

Hello,

Running the "npm install lforms" command in a new project. Defining the following code in Angular in app.component.ts.

image.

I am invoking the script with the libraries in the html.

image

This way I can't use the functions with LForms or I have skipped some import or configuration step.

Greetings, thank you

plynchnlm commented 8 months ago

Can you be more specific about what is going wrong? Are you getting an error somewhere?

I see you are pulling the files from the clinicaltables website as in the demo, which is fine. However, in that case you don't need to run "npm install lforms".

DaniArj1980 commented 8 months ago

Our problem is that we want to create an Angular project which uses part of the lforms functionality, do we need to make calls like, for example, LForms.Util.addFormToPage(fhirQ, 'formContainer'); We can't get it to recognize LForms to be able to invoke the call. We don't know what steps to follow or if we can use part of the functionality in our project.

Greetings, thank you

plynchnlm commented 8 months ago

Yes, that is the API to use. I am not sure why you cannot access LForms. Are the scripts loading successfully? Do you have access to the "window" object? If so, window.LForms should work.

plynchnlm commented 8 months ago

A suggestion from a team member: add "declare var LForms: any;"

Also, you might take a look at the https://github.com/lhncbc/formbuilder-lhcforms (the NLM Form Builder) project, which is an Angular app that uses LForms. It is not a simple example to look at, though. (src/app/services/fetch.service.ts:12:declare var LForms: any;)

DaniArj1980 commented 8 months ago

Hello,

The process I follow is to create a new project called ejemploFormulario3:

PS C:\Curso\Angular> ng new ejemploFormulario3 --standalone=false

I create a new component:

PS C:\Curso\Angular\ejemploFormulario3> ng generate component mi_componente.

The created html file is as follows:

image

The created ps file is as foollows:

image

I understand that it would not be necessary to execute run install lform since it is bringing it from the Githubissues.

  • Githubissues is a development platform for aggregating issues.