You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error of anchor test, the project is just created by anchor init my-project:
Found a 'test' script in the Anchor.toml. Running it as a test suite!
Running test suite: "/Users/hao/git/my-project/Anchor.toml"
yarn run v1.22.5
warning ../package.json: No license field
$ /Users/hao/git/my-project/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
Warning: Cannot find any files matching pattern "./test/**/*.spec.ts"
TSError: ⨯ Unable to compile TypeScript:
tests/my-project.ts(34,23): error TS2304: Cannot find name 'exports'.
tests/my-project.ts(35,29): error TS2591: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
tests/my-project.ts(43,9): error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
at createTSError (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:261:12)
at getOutput (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:367:40)
at Object.compile (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:558:11)
at Module.m._compile (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:439:43)
at Module.m._compile (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:439:23)
at loadTS (node:internal/modules/cjs/loader:1815:10)
at require.extensions.<computed> (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:442:12)
at Object.require.extensions.<computed> [as .ts] (/Users/hao/git/my-project/node_modules/ts-node/src/index.ts:442:12)
at Module.load (node:internal/modules/cjs/loader:1458:32)
at Function._load (node:internal/modules/cjs/loader:1275:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
at Module.require (node:internal/modules/cjs/loader:1480:12)
at require (node:internal/modules/helpers:135:16)
at Object.exports.requireOrImport (/Users/hao/git/my-project/node_modules/mocha/lib/nodejs/esm-utils.js:60:20)
at Object.exports.loadFilesAsync (/Users/hao/git/my-project/node_modules/mocha/lib/nodejs/esm-utils.js:103:20)
at singleRun (/Users/hao/git/my-project/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at Object.exports.handler (/Users/hao/git/my-project/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.
I have tried to install type script env using cmd follows, but it didn't work.
I'm following the example on https://solana.com/zh/docs/intro/installation#install-the-solana-cli. All works well before
anchor test
.error of
anchor test
, the project is just created byanchor init my-project
:I have tried to install type script env using cmd follows, but it didn't work.
node version: v23.7.0
solana version: solana-cli 2.1.14 (src:035c4eb0; feat:3271415109, client:Agave)
anchor version: anchor-cli 0.30.1
How can I fix the problem and run
anchor test
success?The text was updated successfully, but these errors were encountered: