design-first / system-runtime

A JavaScript library that runs systems
https://designfirst.io/systemruntime/
Apache License 2.0
121 stars 35 forks source link

Error while installing a bundle #69

Closed aprelle closed 4 years ago

aprelle commented 4 years ago

Instructions were taken from here: https://designfirst.io/systemruntime/documentation/docs/en/bundle-your-system.html

After the system was defined and saved into a file, I try to load it again using the command:

runtime.install('mysystem.json');

Error: TypeError: $helper.getRuntime(...).system(...).id is not a function ... \node_modules\system-runtime\src\workflow.js:406 .id() at action (... \node_modules\system-runtime\src\workflow.js:406:16)

ecarriou commented 4 years ago

Hi,

you get this error because:

I have updated the library so that you will now have a better error message. Example:

runtime: error when calling the action 'install' on component 'runtime' (class '_Runtime'): Cannot find module '/Users/aaa/project/invalid.json'

aprelle commented 4 years ago

Thanks for a quick response! The new version gives a better error message indeed:

runtime: error when calling the action 'install' on component 'runtime' (class '_Runtime'): Cannot find module 'undefined/MY_PATH_TO_JSON>'

It looks like "undefined/" is added somewhere on the way to the file path.

I found out that combination with fs.readFile may bring you to the positive result:

fs.readFile(MY_PATH_TO_JSON, 'utf8', (err, data) => { runtime.install(data); ...

ecarriou commented 4 years ago

I made some search about your issue and it appears that on Windows 10 the command process.env.PWD (that I use for installing a system) could return undefined. Are you on Windows 10 ?

I made a fix about this issue and I will deploy a new release with that fix very soon.

ecarriou commented 4 years ago

The library has been updated with the fix.

aprelle commented 4 years ago

I am on Windows 10. After the library update the model can be loaded successfully.

Thanks for the quick help!

ecarriou commented 4 years ago

You are welcome. And thank you for having found this issue.

I will close this bug as it seems that your problem is fixed now.

aprelle commented 4 years ago

Hi again, I am wondering, whether it would be possible to provide an absolute path instead of relative by calling runtime.install?

ecarriou commented 4 years ago

Yes, it is possible, I will check how to do that (i.e. if I use the same API or add a new one).