question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve 'path'

See original GitHub issue

I got an error with Angular 11 project

Error: ./node_modules/sanitize-html/node_modules/postcss/lib/input.js
Module not found: Error: Can't resolve 'path' in '/Users/mkrajcir/Devel/BMB/eshop/node_modules/sanitize-html/node_modules/postcss/lib'

Error: ./node_modules/sanitize-html/node_modules/postcss/lib/map-generator.js
Module not found: Error: Can't resolve 'path' in '/Users/mkrajcir/Devel/BMB/eshop/node_modules/sanitize-html/node_modules/postcss/lib'

Error: ./node_modules/sanitize-html/node_modules/postcss/lib/previous-map.js
Module not found: Error: Can't resolve 'path' in '/Users/mkrajcir/Devel/BMB/eshop/node_modules/sanitize-html/node_modules/postcss/lib'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
pentocommented, Feb 2, 2021

@ai: I think this is an issue in the same vein as #971, though it’s likely that path would need a polyfill, rather than just being set to false. This is likely to show up more often, since webpack 5 removed support for automatic polyfills.

If you’d prefer not to add polyfills to postcss, it might be worth updating the Browser docs to note that webpack doesn’t automatically polyfill node APIs any more. Perhaps noting the specific errors that folks might see would help it show up in Google searches. 🙂

For downstream folks wanting to fix this in their own repo, browserify should work (though I haven’t tested it). Alternatively, if you’re using webpack installing path-browserify and adding this to your webpack config should fix it:

resolve: {
	fallback: {
		path: require.resolve( 'path-browserify' ),
	},
},
0reactions
aicommented, Mar 3, 2021

The fix by @mattcompiles was released in 8.2.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'path' - node.js
I'm running in the same problem. I fixed the "stream" error using a tsconfig.json path to readable-stream, but can't figure out a solution...
Read more >
Module not found: Error: Can't resolve 'path' [Solved]
The error "Module not found: Error: Can't resolve 'path'" occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >
Resolve | webpack
Whether to resolve symlinks to their symlinked location. When enabled, symlinked resources are resolved to their real path, not their symlinked location. Note ......
Read more >
Have a JavaScript Module Not Found Error ... - Airbrake Blog
If you see a “Module not found: error can't resolve” JavaScript error, there's likely a problem with the communication between the module you're...
Read more >
Module not found: Error: Can't resolve 'path'_彭世瑜的技术博客
Module not found: Error: Can't resolve 'path',依赖包package.json。
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found