'Solana Test Program Anchor Test failing tsconfig.json" > needs an import assertion of type "json"
I ran anchor test --skip-deploy and all it should do is initialise my program, but all I get is this error, that I cannot resolve. I checked the tsconfig.json settings they should be fine. This is just the most default anchor setup and I'm not importing any unusual json files anywhere.
anchor test --skip-deploy BPF SDK: /Users/julia/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf cargo-build-bpf child: rustup toolchain list -v cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release warning: unused variable:
ctx
--> programs/feeRedeemCounter/src/lib.rs:8:23 | 8 | pub fn initialize(ctx: Context) -> ProgramResult { | ^^^ help: if this is intentional, prefix it with an underscore:_ctx
| = note:#[warn(unused_variables)]
on by defaultwarning:
feeRedeemCounter
(lib) generated 1 warning Finished release [optimized] target(s) in 1.28s cargo-build-bpf child: /Users/julia/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter.soTo deploy this program: $ solana program deploy /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter.so The program address will default to this keypair (override with --program-id): /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/target/deploy/fee_redeem_counter-keypair.json yarn run v1.22.17 warning package.json: No license field $ /Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
TypeError: Module "file:///Users/julia/Downloads/anchorTutorial/feeRedeemCounter/tsconfig.json" needs an import assertion of type "json" at new NodeError (node:internal/errors:371:5) at validateAssertions (node:internal/modules/esm/assert:82:15) at defaultLoad (node:internal/modules/esm/load:24:3) at ESMLoader.load (node:internal/modules/esm/loader:359:26) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58) at new ModuleJob (node:internal/modules/esm/module_job:66:26) at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261:34) at async Promise.all (index 0) at ESMLoader.import (node:internal/modules/esm/loader:337:24) at importModuleDynamicallyWrapper (node:internal/vm/module:437:15) at formattedImport (/Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/mocha/lib/nodejs/esm-utils.js:7:14) at Object.exports.requireOrImport (/Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/mocha/lib/nodejs/esm-utils.js:48:32) at Object.exports.loadFilesAsync (/Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/mocha/lib/nodejs/esm-utils.js:103:20) at singleRun (/Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/mocha/lib/cli/run-helpers.js:125:3) at Object.exports.handler (/Users/julia/Downloads/anchorTutorial/feeRedeemCounter/node_modules/mocha/lib/cli/run.js:374:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Error: Program address not found.
Solution 1:[1]
I fixed my own problem by running
yarn add ts-mocha
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Julia |