Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve 'path' #1509

Closed
mkrajcir opened this issue Jan 10, 2021 · 6 comments · Fixed by #1536
Closed

Can't resolve 'path' #1509

mkrajcir opened this issue Jan 10, 2021 · 6 comments · Fixed by #1536

Comments

@mkrajcir
Copy link

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'
@Semigradsky
Copy link
Member

Also apostrophecms/sanitize-html#431

Looks like sanitize-html used in the browser so node's dependencies not available.

@ai
Copy link
Member

ai commented Jan 11, 2021

Talk to sanitize-html or Angular builder tool. I can’t help in invastigation.

Open an issue again if you will need some explicit changed in postcss.

@ai ai closed this as completed Jan 11, 2021
@solblog
Copy link

solblog commented Jan 28, 2021

I have exactly the same problem:
ERROR in ./node_modules/sanitize-html/node_modules/postcss/lib/input.js
Module not found: Error: Can't resolve 'path' in 'node_modules\sanitize-html\node_modules\postcss\lib'

@pento
Copy link

pento commented 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' ),
	},
},

@ai
Copy link
Member

ai commented Feb 3, 2021

Polyfill for path will be too huge. We need to add package.browser.path: false (so even webpack 4 will not insert the polyfill) and prepare code to work without path.

I just do not have time since I work on another open-source project.

Please send PR (you can see how we deal with fs dependency as a reference).

@ai
Copy link
Member

ai commented Mar 3, 2021

The fix by @mattcompiles was released in 8.2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants