Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can no longer import fs FileSystem

ANSWERED

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?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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.

Best Answer
0 Votes

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.

Best Answer
0 Votes