TypeError: Module “file:///Users/user/Desktop/../tsconfig.json” needs an import assertion of type “json” Error: Your configured rpc port: 8899 is already in use | Solana anchor run test |
anchor test — skip-local-validator
Ever ran this command after running a local ledger through ‘solana-test-validator’, ‘anchor build’ and ‘anchor deploy’—
anchor run test
And encountered this error? →
TypeError: Module “file:///Users/user/Desktop/../tsconfig.json” needs an import assertion of type “json”
Or
Error: Your configured rpc port: 8899 is already in use
And finally,
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Solution —
Run this command →
yarn add ts-mocha
You should see similar output such as these →
yarn add v1.22.18
warning package.json: No license field
warning No license field
[1/4] 🔍 Resolving packages…
[2/4] 🚚 Fetching packages…
[3/4] 🔗 Linking dependencies…
[4/4] 🔨 Building fresh packages…
success Saved lockfile.
warning No license field
warning “ts-mocha” is already in “devDependencies”. Please remove existing entry first before adding it to “dependencies”.
success Saved 1 new dependency.
info Direct dependencies
└─ ts-mocha@10.0.0
info All dependencies
└─ ts-mocha@10.0.0
✨ Done in 1.75s.
Then run this again →
anchor run test
You should be able to see similar outputs →
yarn run v1.22.18
warning package.json: No license field
……
Your transaction signature …
✔ Is initialized! (471ms)1 passing (474ms)✨ Done in 6.36s.
There you go, you have the test passing!
Alternatively, you might want to try running this command —
anchor test — skip-local-validator