Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

node index.js Error reading file #15

Closed
kazzazed opened this issue Nov 14, 2021 · 5 comments
Closed

node index.js Error reading file #15

kazzazed opened this issue Nov 14, 2021 · 5 comments

Comments

@kazzazed
Copy link

kazzazed commented Nov 14, 2021

I'm not a developer so stumbling around a little with this.. can anyone assist me with this error? I've got nodejs installed running latest version, and updated npm. I downloaded the zip file and extracted it to c:\temp, so the files are in c:\temp\import-ynab5-master. From that path I ran npm i in bash to install the libraries.
Then with Actual running, in command prompt, I cd to that directory and run node index.js /budget.json and get 'Error Reading File'. I get the same error if I don't give a file name (node index.js). The budget file I downloaded is in the same directory, so not adding a path to that file name (have also tried putting in the full file path/name, same result).

I have set permissions on the folders to Everyone full access, as well as local machine users (needed to do that to write the file from ynab).
Is anyone able to assist me with this? is it a permissions issue? version issue?

Running W10 latest version.
WLS2
Default node v16.13.0 (have also installed 17.1.0 and running that get same issue)
npm version 8.1.3
Any assistance or pointers appreciated.

Directory of C:\Temp\import-ynab5-master

14/11/2021 06:17 PM

.
14/11/2021 06:17 PM ..
14/11/2021 05:39 PM 12 .gitignore
14/11/2021 12:30 PM 2,106,753 budget.json
14/11/2021 05:39 PM 4,525 example.json
14/11/2021 05:39 PM 9,517 importer.js
14/11/2021 05:39 PM 179 index.js
14/11/2021 05:42 PM node_modules
14/11/2021 07:12 PM 5,222 package-lock.json
14/11/2021 05:39 PM 587 package.json
14/11/2021 05:39 PM 1,158 README.md
14/11/2021 07:12 PM 1,898 yarn.lock
9 File(s) 2,129,851 bytes
3 Dir(s) 148,388,691,968 bytes free

C:\Temp\import-ynab5-master>bash
[user@laptop]:/mnt/c/Temp/import-ynab5-master$ node index.js /budget.json
Error: Error reading file
at importYNAB5 (/mnt/c/Temp/import-ynab5-master/importer.js:319:11)
at run (/mnt/c/Temp/import-ynab5-master/index.js:6:9)
at Object. (/mnt/c/Temp/import-ynab5-master/index.js:9:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
[user@laptop]:/mnt/c/Temp/import-ynab5-master$

@ashraymehta
Copy link
Contributor

Hey @kazzazed! It sounds like the importer is unable to find the file at the specified path.

Since the file (budget.json) is in the same directory where you're running the command from, the command should probably be:

node index.js ./budget.json

Please note the . before the /budget.json, that's an important one.

Hope this helps!

@kazzazed
Copy link
Author

@ashraymehta , thanks for responding.
If I add the stop I get 'Couldn't connect to Actual' (which is running). I get that same error if I mistype the file name.
I have also tried specifying the full path, and also moving the budget file to another path and specifying that. Both cases I still get the error reading file.
I've tried running in command prompt, powershell in Administrator mode, and in Ubuntu 20.04 lts. All have the same result.
It's driving me nuts :(

[user@laptop]:/mnt/c/Temp/import-ynab5-master$ node index.js ./budget.json
Error: Couldn't connect to Actual. Please run the app first.
at init (/mnt/c/Temp/import-ynab5-master/node_modules/@actual-app/api/connection.js:44:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async _run (/mnt/c/Temp/import-ynab5-master/node_modules/@actual-app/api/connection.js:90:5)
at async run (/mnt/c/Temp/import-ynab5-master/index.js:6:3)
[user@laptop]:/mnt/c/Temp/import-ynab5-master$

also tried specifying full path:

C:\Temp\import-ynab5-master>bash
[user@laptop]:/mnt/c/Temp/import-ynab5-master$ node index.js /mnt/C/Temp/import-ynab5-master/budget.json
Error: Error reading file
at importYNAB5 (/mnt/c/Temp/import-ynab5-master/importer.js:319:11)
at run (/mnt/c/Temp/import-ynab5-master/index.js:6:9)
at Object. (/mnt/c/Temp/import-ynab5-master/index.js:9:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47

@ashraymehta
Copy link
Contributor

Hey @kazzazed. I tried it on my Windows PC and I faced the same issue as you when I ran it from WSL (Couldn't connect to Actual. Please run the app first.). It seems that the importer can't connect to the Actual application from WSL. However, when I run it from Powershell (without WSL), it seems to work.

The command from Powershell would be the same one I posted above: node index.js ./budget.json.

Please note that I did not enter bash before running the command. It was from Powershell itself. This means that you'd have to install Node.js on Windows (https://nodejs.org/en/download/), if you don't have it already.

Hope this sorts it out for you!

@kazzazed
Copy link
Author

@ashraymehta thank you! That worked perfectly. I was following the readme here on github which had everything running under WLS and using bash, so thought that I needed to do that. Did not realise I could execute js directly in W10. Thanks again 😃

@jlongster
Copy link
Contributor

I added a note about WSL a little while ago. Thanks for the help @ashraymehta !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants