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

Attempted import error: 'validate' is not exported from 'csstree-validator'. #30

Open
prathamesh-bigpi opened this issue Jun 20, 2022 · 4 comments

Comments

@prathamesh-bigpi
Copy link

prathamesh-bigpi commented Jun 20, 2022

I have installed "csstree-validator": "^3.0.0", version and imported in react application
import { validate } from 'csstree-validator';
Trying to run it but getting following error
Attempted 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.

@cakeinpanic
Copy link

Same issue, using [email protected], 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 }

@cakeinpanic
Copy link

@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';

@cakeinpanic
Copy link

btw your solution does not work for me neither :(

@ba32107
Copy link

ba32107 commented Feb 19, 2024

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.

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

No branches or pull requests

3 participants