enhanced-resolve: Can't resolve 'pnpapi' with webpack 5.4.0
ERROR in ./node_modules/enhanced-resolve/lib/ResolverFactory.js 118:9-26
Module not found: Error: Can't resolve 'pnpapi' in 'C:\Users\david\Projects\electron-react @ ./node_modules/enhanced-resolve/lib/index.js 10:24-52
@ ./node_modules/webpack/lib/ResolverFactory.js 8:16-59
@ ./node_modules/webpack/lib/Compiler.js 25:24-52
@ ./node_modules/webpack/lib/index.js 114:9-30
@ ./src/js/App.js 2:0-35
@ ./src/js/index.js 3:0-24 5:50-53
Here’s my package.json as well
{
"name": "electron-react",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --config webpack.common.js --watch",
"start": "electron ."
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"electron": "^10.1.5",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.5",
"babel-loader": "^8.2.1",
"css-loader": "^5.0.1",
"electron-reload": "^1.5.0",
"sass": "^1.29.0",
"sass-loader": "^10.1.0",
"style-loader": "^2.0.0",
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0"
}
}
From what I’ve heard, pnpapi is built into webpack now, and that might be causing some conflict? I commented out line 118 in lib/ResolverFactory.js and webpack compiles fine after that.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Update ResolverFactory.js Issue #263 is preventing my company from upgrading to Webpack v5. This was the proposed fix that worked well for us so I created a PR. — committed to dlredden/enhanced-resolve by deleted user 3 years ago
- Repro for webpack/enhanced-resolve#263 w/yarn 3.2 — committed to jscheid/enhanced-resolve-263 by jscheid 2 years ago
- chore: patch enhanced-resolve to properly discover the pnp api for the yarn_v3.1.1_pnp_spec.ts system test. see https://github.com/webpack/enhanced-resolve/issues/263 for more details — committed to cypress-io/cypress by AtofStryker a year ago
- chore: patch enhanced-resolve to properly discover the pnp api for the yarn_v3.1.1_pnp_spec.ts system test. see https://github.com/webpack/enhanced-resolve/issues/263 for more details — committed to cypress-io/cypress by AtofStryker a year ago
- chore: patch enhanced-resolve to properly discover the pnp api for the yarn_v3.1.1_pnp_spec.ts system test. see https://github.com/webpack/enhanced-resolve/issues/263 for more details — committed to cypress-io/cypress by AtofStryker a year ago
- chore: patch enhanced-resolve to properly discover the pnp api for the yarn_v3.1.1_pnp_spec.ts system test. see https://github.com/webpack/enhanced-resolve/issues/263 for more details — committed to cypress-io/cypress by AtofStryker a year ago
- chore: update to webpack v5 (#27438) * chore: [run ci] does further prerequisites for webpack 5: https://webpack.js.org/migrate/5/#make-sure-your-build-has-no-errors-or-warnings https://webpack.js.... — committed to cypress-io/cypress by AtofStryker a year ago
I stopped getting the aformentioned error by changing
./node_modules/webpack/node_modules/enhanced-resolve/lib/ResolverFactory.js 118:9-26
toreturn require("./PnpPlugin").PnpApiImpl
I don’t know if this was the correct way to go about this though…
I’m still getting this error, but with yarn berry.
https://github.com/webpack/enhanced-resolve/commit/f08fe3f1a22c90c722eca14b38a9300ad00c62e8 seems to be released in
5.8.0
Exact same error as @DavidTanner here, using enhanced-resolve 5.9.2, Yarn 3.2.0 and Jest 27.5.1. Repro: https://github.com/jscheid/enhanced-resolve-263