#Unable to import the ZkProgram from o1js

27 messages · Page 1 of 1 (latest)

devout tiger
#

Now that the Experimental is deprecated we are importing ZkProgram directly but when I am trying to do so I am getting the following error: Module '"o1js"' has no exported member 'ZkProgram'.

#

So, I am importing from here : import { ZkProgram } from 'o1js/dist/node/lib/proof_system';

But while compiling I am getting the following issue:

#

I am on this version.

#

@deft cedar

#

Seriously dude you trying to scam me ?

Username: harmonica4539
User ID: 1084850830672404540

@manic marlin

devout tiger
devout tiger
#

@deft cedar

zenith crag
#
import { ZkProgram } from "o1js";
devout tiger
zenith crag
#

Check your tsconfig.json. It should have options like those:

  "compilerOptions": {
    "target": "es2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
    "lib": ["es2021", "dom"],
    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
    "outDir": "./dist/lib/ts" /* Redirect output structure to the directory. */,
    "strict": true /* Enable all strict type-checking options. */,
    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
    "skipLibCheck": true /* Skip type checking of declaration files. */,
    "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
    "composite": true,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "strictPropertyInitialization": false
  },
devout tiger
#

I can see this:

{
  "compilerOptions": {
    "target": "es2020",
    "module": "es2022",
    "lib": ["dom", "esnext"],
    "outDir": "./build",
    "rootDir": ".",
    "strict": true,
    "strictPropertyInitialization": false, // to enable generic constructors, e.g. on CircuitValue
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowJs": true,
    "declaration": true,
    "sourceMap": true,
    "noFallthroughCasesInSwitch": true,
    "allowSyntheticDefaultImports": true
  },
  "include": ["./src"]
}

#

Should I change it ?

zenith crag
#

Yes, you can try to change options and see if it will help or not. Also, if you use yarn, it can be the result of PnP

devout tiger
#

Oh Okay.
I am using npm.

#

Let me try

zenith crag
#

Also, try to move o1js from peerDependencies to dependencies

zenith crag
#

and fresh npm install after removing all npm files can also help

devout tiger
#

Okay

#

o1js version need to be change right ?

zenith crag
#

I would put the 0.14.1 or 0.14.2

devout tiger
#

Okay will try with 0.14.1 if still didn't worked will try with .2

#

Thanks alot.
Let me try and share if it works or not

zenith crag
#

I've upgraded today typescript dependencies and have got similar errors for jest, o1js, etc...
Downgraded the typescript back, and now everything is working again. Those are my versions:

? Pick the packages you want to upgrade.          Current          Range            Latest

 > @types/jest --------------------------------- ◉ ^29.5.8 ------ ◯ ^29.5.10 -----
   @typescript-eslint/eslint-plugin ------------ ◉ ^6.10.0 ------ ◯ ^6.12.0 ------
   @typescript-eslint/parser ------------------- ◉ ^6.10.0 ------ ◯ ^6.12.0 ------
   axios --------------------------------------- ◉ ^1.6.1 ------- ◯ ^1.6.2 -------
   eslint -------------------------------------- ◉ ^8.53.0 ------ ◯ ^8.54.0 ------
   prettier ------------------------------------ ◉ 3.0.3 -------- ◯ 3.1.0 --------
   typescript ---------------------------------- ◉ 5.2.2 -------- ◯ 5.3.2 --------
devout tiger
#

Oh Okay.

lean fiber
#

Have you put a name to your zk program