我正在使用
yarn (1.22)
和 parcel(2.9.3)
包构建一个 React Web 应用程序,并在控制台中收到此错误:-
Uncaught Error: Could not resolve bundle with id bundle-manifest.js:13 runtime-49a0cc4de56a254e.js:1 in the browser (firefox, chrome)
有人通过包裹构建解决了这个问题吗?
应用程序似乎在 azure DevOps 中构建得很好。
为了解决您的错误,请确保在本地代码中重新安装软件包,然后将更改推送到 Azure DevOps 存储库中,如下所示:-
npm i [email protected]
npm i parcel
npm audit fix
我的package.json:-
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-private-property-in-object": "^7.22.11",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"swiper": "^10.0.4",
"web-vitals": "^2.1.4",
"yarn": "^1.22.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
尝试更新 npm 模块并清理缓存:-
npm install -g npm
npm cache clean --force
我的 DevOps 构建 yaml 脚本:-
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: |
npm install
npm run build
displayName: 'npm install and build'
输出:-