字段 'browser' 不包含 Cypress 中的有效别名配置
Field 'browser' doesn't contain a valid alias configuration in Cypress
Guys cypress 显示以下错误消息。我相信错误发生是因为我安装了一些插件,但我不能说是哪一个。有人可以帮忙吗?
Error: Webpack Compilation Error
./cypress/support/commands.js
Module not found: Error: Can't resolve 'cypress' in 'C:\Dev\Projeto_Alper_Caixa\cypress\support'
resolve 'cypress' in 'C:\Dev\Projeto_Alper_Caixa\cypress\support'
Parsed request is a module
using description file: C:\Dev\Projeto_Alper_Caixa\package.json (relative path: ./cypress/support)
Field 'browser' doesn't contain a valid alias configuration
Looked for and couldn't find the file at the following paths:
[C:\Dev\Projeto_Alper_Caixa\cypress\support\node_modules]
[C:\Dev\Projeto_Alper_Caixa\cypress\node_modules]
[C:\Dev\node_modules]
[C:\node_modules]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.js]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.json]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.jsx]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.mjs]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.coffee]
@ ./cypress/support/commands.js 5:38-56
@ ./cypress/support/index.js
at Watching.handle [as handler] (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\@cypress\webpack-preprocessor\dist\index.js:180:23)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:99:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Watching._done (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:98:28)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:73:19
at Compiler.emitRecords (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:499:39)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:54:20
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:485:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:482:27
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:2818:7
at done (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:3522:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:464:33
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\graceful-fs\graceful-fs.js:111:16
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\enhanced-resolve\node_modules\graceful-fs\graceful-fs.js:61:14
Alright so during the troubleshoot our goal would be to reach the nearest version of node required as we can see in below error logs.
-bash-3.2$ npm update
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '14.17.0' },
npm WARN EBADENGINE current: { node: 'v17.2.0', npm: '8.1.0' }
npm WARN EBADENGINE }
added 7 packages, removed 6 packages, changed 57 packages, and audited 350 packages in 11s
64 packages are looking for funding
run npm fund for details
added 7 packages, removed 6 packages, changed 57 packages, and audited 350 packages in 11s
64 packages are looking for funding
run `npm fund` for details
As we currently have 17.2.0 and the required is 14.17.0. To fix this
npm cache clear
npm cache clean --force
npm install -g cypress
sudo n 14.17.0
rm -rf **put your existing version**. {Perform this in the folder where your previous version of node was installed}
Open a new terminal
node -v
npm install
npx cypress open
**This works for mac, not tried in windows/ubuntu
Guys cypress 显示以下错误消息。我相信错误发生是因为我安装了一些插件,但我不能说是哪一个。有人可以帮忙吗?
Error: Webpack Compilation Error
./cypress/support/commands.js
Module not found: Error: Can't resolve 'cypress' in 'C:\Dev\Projeto_Alper_Caixa\cypress\support'
resolve 'cypress' in 'C:\Dev\Projeto_Alper_Caixa\cypress\support'
Parsed request is a module
using description file: C:\Dev\Projeto_Alper_Caixa\package.json (relative path: ./cypress/support)
Field 'browser' doesn't contain a valid alias configuration
Looked for and couldn't find the file at the following paths:
[C:\Dev\Projeto_Alper_Caixa\cypress\support\node_modules]
[C:\Dev\Projeto_Alper_Caixa\cypress\node_modules]
[C:\Dev\node_modules]
[C:\node_modules]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.js]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.json]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.jsx]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.mjs]
[C:\Dev\Projeto_Alper_Caixa\node_modules\cypress.coffee]
@ ./cypress/support/commands.js 5:38-56
@ ./cypress/support/index.js
at Watching.handle [as handler] (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\@cypress\webpack-preprocessor\dist\index.js:180:23)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:99:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Watching._done (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:98:28)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:73:19
at Compiler.emitRecords (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:499:39)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:54:20
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:485:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:482:27
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:2818:7
at done (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:3522:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:464:33
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\graceful-fs\graceful-fs.js:111:16
at C:\Users\losp\AppData\Local\Cypress\Cache.7.0\Cypress\resources\app\packages\server\node_modules\enhanced-resolve\node_modules\graceful-fs\graceful-fs.js:61:14
Alright so during the troubleshoot our goal would be to reach the nearest version of node required as we can see in below error logs.
-bash-3.2$ npm update
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '14.17.0' },
npm WARN EBADENGINE current: { node: 'v17.2.0', npm: '8.1.0' }
npm WARN EBADENGINE }
added 7 packages, removed 6 packages, changed 57 packages, and audited 350 packages in 11s
64 packages are looking for funding
run npm fund for details
added 7 packages, removed 6 packages, changed 57 packages, and audited 350 packages in 11s
64 packages are looking for funding
run `npm fund` for details
As we currently have 17.2.0 and the required is 14.17.0. To fix this
npm cache clear
npm cache clean --force
npm install -g cypress
sudo n 14.17.0
rm -rf **put your existing version**. {Perform this in the folder where your previous version of node was installed}
Open a new terminal
node -v
npm install
npx cypress open
**This works for mac, not tried in windows/ubuntu