05-13-2018 04:57 - edited 05-13-2018 06:13
05-13-2018 04:57 - edited 05-13-2018 06:13
I'm trying to call
var player = fs.readFileSync("pdc-hatch-save.txt", "json").player;
from the companion/index.js file - but I get this error:
fs is imported by companion/index.js, but could not be resolved
Is there a way to resolve the issue?
EDIT:
now all my fs imports are not working. This started becoming an issue when I moved some files to the common folder. Is there a reason I would be getting these errors?
Answered! Go to the Best Answer.
05-13-2018 16:57
05-13-2018 16:57
Silly me - you can't use the FileSystem for companion files, and these files were being imported by the companion index.js, so that's why the errors occured.
Removing the import in files used by the companion and fixed this up.
05-13-2018 16:57
05-13-2018 16:57
Silly me - you can't use the FileSystem for companion files, and these files were being imported by the companion index.js, so that's why the errors occured.
Removing the import in files used by the companion and fixed this up.
02-01-2019 08:08 - edited 02-02-2019 16:48
02-01-2019 08:08 - edited 02-02-2019 16:48
Where did you end up importing the filesystem? Nevermind I worked around it. You can use anything you want in the Companion API as long as you rollup your js dependancies with commonjs. Also, if you use the /common/ directory in the app architecture that will share those dependancies between /app/ and /companion/. I will say its a huge pain in the **ahem** to get what you want out of rollup but its definitely the only way to get needed dependanxies for app development. I wish you could just add npm packages that were shared across the application like regular ReactJS.