Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find package.json in directory #57

Closed
Fattah-Saqib opened this issue Aug 2, 2020 · 10 comments
Closed

Can't find package.json in directory #57

Fattah-Saqib opened this issue Aug 2, 2020 · 10 comments

Comments

@Fattah-Saqib
Copy link

Whenever I put any snarkjs command it shows the following but the package.json file is present in that directory.

 internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open '\C:\Users\fattah\AppData\Roaming\npm\node_modules\snarkjs\package.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (C:\Users\fattah\AppData\Roaming\npm\node_modules\snarkjs\build\cli.cjs:1232:15)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: '\\C:\\Users\\fattah\\AppData\\Roaming\\npm\\node_modules\\snarkjs\\package.json'
}
@benjaminstrasser
Copy link

I am having the same problem

@jbaylina
Copy link
Member

This looks like a windows problem..

@vanmoortel
Copy link

Yes, the problem is that there is a backslash at the beginning of the path.
Here is a temporary fix for windows users:

Update line 1154 of your-project/node_modules/snarkjs/build/cli.cjs
Before:
pkgS = fs.readFileSync(path.join(__dirname$1, "..","package.json"));
After
pkgS = fs.readFileSync(path.join(__dirname$1.slice(1,__dirname$1.length), "..","package.json"));

@calvbore
Copy link

Having this issue on windows as well.

internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open '\C:\Users\Calvin\AppData\Roaming\npm\node_modules\snarkjs\package.json'
�[90m    at Object.openSync (fs.js:462:3)�[39m
�[90m    at Object.readFileSync (fs.js:364:35)�[39m
    at Object.<anonymous> (C:\Users\Calvin\AppData\Roaming\npm\node_modules\�[4msnarkjs�[24m\build\cli.cjs:1310:35)
�[90m    at Module._compile (internal/modules/cjs/loader.js:1137:30)�[39m
�[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)�[39m
�[90m    at Module.load (internal/modules/cjs/loader.js:985:32)�[39m
�[90m    at Function.Module._load (internal/modules/cjs/loader.js:878:14)�[39m
�[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)�[39m
�[90m    at internal/main/run_main_module.js:17:47�[39m {
  errno: �[33m-4058�[39m,
  syscall: �[32m'open'�[39m,
  code: �[32m'ENOENT'�[39m,
  path: �[32m'\\C:\\Users\\Calvin\\AppData\\Roaming\\npm\\node_modules\\snarkjs\\package.json'�[39m
}

@Hengkai-Ye
Copy link

For 0.3.59, update line 151 of /node_modules/snarkjs/build/cli.cjs with

pkgS = fs__default['default'].readFileSync(path__default['default'].join(__dirname$1.slice(1,__dirname$1.length), "..","package.json"));

@calvbore
Copy link

calvbore commented Mar 18, 2021

also for v0.3.59, changed line 5744 of /node_modules/snarkjs/build/cli.cjs to:

templateName = fs__default['default'].readFileSync(path__default['default'].join(__dirname$2.slice(1,__dirname$1.length), "..","templates","verifier_groth16.sol"));

and haven't run into any issues on windows yet.

@tippi-fifestarr
Copy link

Using Node 14.15.0 npm install -g snarkjs@latest installs "correctly" but no node_modules or package.json are created

@Komari-Koshigaya
Copy link

also for v0.3.59, changed line 5744 of /node_modules/snarkjs/build/cli.cjs to:

templateName = fs__default['default'].readFileSync(path__default['default'].join(__dirname$2.slice(1,__dirname$1.length), "..","templates","verifier_groth16.sol"));

and haven't run into any issues on windows yet.

Is this problem still unresolved?
I have the same problem, and there is another question after taking your approach

F:\tutorial\factor> snarkjs info -c circuit.json
[ERROR] snarkJS: Error: circuit.json: Invalid File format
at Object.readBinFile (G:\ProgrammingSoftware\front-end\node-v14.15.0-win-x64\node_modules\snarkjs\node_modules@iden3\binfileutils\build\main.cjs:16:35)
at async Object.readR1cs (G:\ProgrammingSoftware\front-end\node-v14.15.0-win-x64\node_modules\snarkjs\node_modules\r1csfile\build\main.cjs:112:28)
at async r1csInfo (G:\ProgrammingSoftware\front-end\node-v14.15.0-win-x64\node_modules\snarkjs\build\cli.cjs:154:17)
at async Object.r1csInfo$1 [as action] (G:\ProgrammingSoftware\front-end\node-v14.15.0-win-x64\node_modules\snarkjs\build\cli.cjs:8146:5)
at async clProcessor (G:\ProgrammingSoftware\front-end\node-v14.15.0-win-x64\node_modules\snarkjs\build\cli.cjs:282:21)

@ddengster
Copy link

This problem has re-emerged on windows again, v0.4.15

I fixed it via the this code block in PR #88 : https://github.com/iden3/snarkjs/pull/88/files#diff-479f878ecd4b45fdc75718d1eedb8d4385d08d50264852cc6c0570ec310c1733R152 and changing the __dirname$1 to __dirname$2

@phated
Copy link
Contributor

phated commented Apr 7, 2022

I believe this was fixed by #131 - please update to snarkjs 0.4.16 and try again.

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

Successfully merging a pull request may close this issue.

10 participants