英文:
Unable to run Cypress open command in Next.js project with Typescript
问题
我无法运行Cypress open在我的Next.js项目中使用TypeScript。运行命令后,我得到以下结果。
mohitnayak@Mohits-MacBook-Pro todo-app % npm run cypress:open
> todo-app@0.1.0 cypress:open
> cypress open
DevTools listening on ws://127.0.0.1:50474/devtools/browser/067ddcd9-221c-4042-8544-08d3598b88d7
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
at createTSError (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311:16)
at reportTSError (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:314:23)
at /Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:686:17
at Object.compile (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:743:35)
at Module.m._compile (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:856:36)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Object.require.extensions.<computed> [as .js] (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Function.Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
diagnosticCodes: [ 5095 ]
}
这是一个基本的待办事项应用程序。以下是打开GitHub仓库的链接。请帮助我为项目运行Cypress。
GitHub仓库
英文:
I'm unable to run Cypress open in my Next.js project with Typescript. Here's what I get after running the command.
`mohitnayak@Mohits-MacBook-Pro todo-app % npm run cypress:open
> todo-app@0.1.0 cypress:open
> cypress open
DevTools listening on ws://127.0.0.1:50474/devtools/browser/067ddcd9-221c-4042-8544-08d3598b88d7
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
at createTSError (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311:16)
at reportTSError (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:314:23)
at /Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:686:17
at Object.compile (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:743:35)
at Module.m._compile (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:856:36)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Object.require.extensions.<computed> [as .js] (/Users/mohitnayak/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Function.Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
diagnosticCodes: [ 5095 ]
}
`
It's basic todo app. Here's the link to the open GitHub repo. Please help me running Cypress for the project.
GitHub repo
答案1
得分: 4
前往您的tsconfig.json文件并更新该文件中moduleResolution的值。
例如:
"moduleResolution": "node"
在这里,您需要将值"bundler"替换为"node"。
我已测试过,这个更改可以正常工作。
更新后的结果:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论