coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.69k stars 1.35k forks source link

anchor migrate broken #1295

Open utx0 opened 2 years ago

utx0 commented 2 years ago

I have just tried to use anchor migrate on a new project and found that its throwing the following error which I cant seam to solve.

This happen on a new/vanilla project too.

❯ anchor -V
anchor-cli 0.20.1
❯ anchor migrate
Running migration deploy script

/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS2688: Cannot find type definition file for 'chai'.
  The file is in the program because:
    Entry point of type library 'chai' specified in compilerOptions
deploy.ts(10,34): error TS2576: Property 'local' does not exist on type 'NodeWallet'. Did you mean to access the static member 'NodeWallet.local' instead?

    at createTSError (/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:558:11)
    at Module.m._compile (/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Object.require.extensions.<computed> [as .ts] (/home/utx0/Code/anchor_new/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (node:internal/modules/cjs/loader:975: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 Object.<anonymous> (/home/utx0/Code/anchor_new/node_modules/ts-node/src/bin.ts:157:12)
Deploy failed.

Was wanting to use this to be able to kick off calls to my initialize instructions, however I cant get this to work regardless of what I have the cluster set to as well.

hsubra89 commented 2 years ago

Based on what the error says; you're just missing some type definitions. Try running this in your root project folder :

# If using yarn
yarn add -D @types/chai

# or is using nom
npm install --save-dev @types/chai
utx0 commented 2 years ago

Yeah added this to my vanllia project.

❯ git diff package.json
diff --git a/package.json b/package.json
index 82135e7..fb643e7 100644
--- a/package.json
+++ b/package.json
@@ -3,10 +3,11 @@
         "@project-serum/anchor": "^0.20.1"
     },
     "devDependencies": {
+        "@types/chai": "^4.3.0",
+        "@types/mocha": "^9.0.0",
         "chai": "^4.3.4",
         "mocha": "^9.0.3",
         "ts-mocha": "^8.0.0",
-        "@types/mocha": "^9.0.0",
         "typescript": "^4.3.5"
     }
 }

Still getting the following error on a brand new anchor project with no changes.

❯ anchor migrate
Running migration deploy script

/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
deploy.ts(10,34): error TS2576: Property 'local' does not exist on type 'NodeWallet'. Did you mean to access the static member 'NodeWallet.local' instead?

    at createTSError (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:558:11)
    at Module.m._compile (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Object.require.extensions.<computed> [as .ts] (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (node:internal/modules/cjs/loader:975: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 Object.<anonymous> (/home/utx0/Code/me/anchor_vanillia/node_modules/ts-node/src/bin.ts:157:12)
Deploy failed.