Open prathamesh-bigpi opened 2 years ago
Same issue, using csstree-validator@3.0.0
, upgraded my webpack to version 5 and getting
Error: Module not found: Error: Package path ./dist/csstree-validator.js is not exported from package node_modules/csstree-validator (see exports field in node_modules/csstree-validator/package.json)
if using import { validate } from 'csstree-validator';
,
getting this
./node_modules/csstree-validator/lib/helpers.js:2:0-37 - Error: Module not found: Error: Can't resolve 'path' in '/Users/kpavlenko/projects/communication-app/node_modules/csstree-validator/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
@prathamesh-bigpi if you are using webpack 4, this may help you(used to work for us before an upgrade)
import { validate } from 'csstree-validator/dist/csstree-validator.esm.js';
btw your solution does not work for me neither :(
Same issue here. It doesn't even work when I use require
:
[ERROR] Could not resolve "fs"
node_modules/csstree-validator/cjs/helpers.cjs:3:19:
3 │ const fs = require('fs');
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "--platform=node" to do that, which will remove this error.
✘ [ERROR] Could not resolve "path"
node_modules/csstree-validator/cjs/helpers.cjs:4:21:
4 │ const path = require('path');
╵ ~~~~~~
The package "path" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "--platform=node" to do that, which will remove this error.
I have installed
"csstree-validator": "^3.0.0",
version and imported in react applicationimport { validate } from 'csstree-validator';
Trying to run it but getting following errorAttempted import error: 'validate' is not exported from 'csstree-validator'.
csstree_validator__WEBPACK_IMPORTED_MODULE_13__.default.validate is not a function
After changing import statement to
import { validate } from 'csstree-validator/lib/validate';
the code is working fine. Is this a known issue ?Note: version 2.0.1 is working fine.