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

Duplicite browserlist #781

Open
erichstark opened this issue May 26, 2020 · 1 comment
Open

Duplicite browserlist #781

erichstark opened this issue May 26, 2020 · 1 comment

Comments

@erichstark
Copy link

Hello, I have got error because of duplicity browserlist. It should be propably only at one place.

[15:24:13] Plumber found unhandled error:
 BrowserslistError in plugin "gulp-postcss"
Message:
    /Volumes/Data/Projects/xxx contains both browserslist and package.json with browsers
Details:
    browserslist: true
    fileName: /Volumes/Data/Projects/xxx/app/styles/main.css

Stack:
BrowserslistError: /Volumes/Data/Projects/xxx contains both browserslist and package.json with browsers
    at /Volumes/Data/Projects/xxx/node_modules/browserslist/node.js:309:15
    at eachParent (/Volumes/Data/Projects/xxx/node_modules/browserslist/node.js:48:18)
    at Object.findConfig (/Volumes/Data/Projects/xxx/node_modules/browserslist/node.js:285:20)
    at Function.loadConfig (/Volumes/Data/Projects/xxx/node_modules/browserslist/node.js:218:37)
    at browserslist (/Volumes/Data/Projects/xxx/node_modules/browserslist/index.js:411:31)
    at Browsers.parse (/Volumes/Data/Projects/xxx/node_modules/autoprefixer/lib/browsers.js:64:12)
    at new Browsers (/Volumes/Data/Projects/xxx/node_modules/autoprefixer/lib/browsers.js:46:26)
    at loadPrefixes (/Volumes/Data/Projects/xxx/node_modules/autoprefixer/lib/autoprefixer.js:97:20)
    at plugin (/Volumes/Data/Projects/xxx/node_modules/autoprefixer/lib/autoprefixer.js:108:20)
    at LazyResult.run (/Volumes/Data/Projects/xxx/node_modules/postcss/lib/lazy-result.js:295:14)
[15:24:13] Finished 'styles' after 391 ms
[15:24:13] Finished 'modernizr' after 391 ms
[15:24:14] Plumber found unhandled error:
 BrowserslistError in plugin "gulp-babel"
Message:
    [BABEL] /Volumes/Data/Projects/xxx/app/scripts/main.js: /Volumes/Data/Projects/xxx contains both browserslist and package.json with browsers (While processing: "/Volumes/Data/Projects/xxx/node_modules/@babel/preset-env/lib/index.js")
@yuvashrikarunakaran
Copy link

  1. Choose One Browserslist Location
    You should use only one source for defining browser compatibility in your project, either:

In the .browserslistrc file (or browserslist file), or
Inside package.json under the browserslist key.
Solution Options:
Option 1: Use package.json for browserslist:
If you want to keep browserslist config in your package.json, remove the .browserslistrc or browserslist file from your project root.
Option 2: Use a dedicated .browserslistrc or browserslist file:
If you prefer to manage the browserslist separately, remove the browserslist section from package.json and keep the .browserslistrc or browserslist file.
2. Ensure Browserslist Configuration is Properly Formatted
If you use the .browserslistrc or browserslist file, make sure it is properly formatted. It should look something like this:

Example of .browserslistrc or browserslist file:

markdown
Copy code

1%
last 2 versions
not dead
If you want to define it inside package.json, it should look like this:

json
Copy code
{
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
3. Remove Conflicting Entries
If you are using both, make sure to delete one:
Delete .browserslistrc or browserslist from the project folder if package.json has browserslist.
OR
Remove the browserslist from package.json if you want to keep the .browserslistrc or browserslist file.
4. Clear Node Modules Cache (Optional)
Sometimes, browserslist conflicts are cached. After making changes, it’s a good idea to clear the node_modules cache and reinstall dependencies:

bash
Copy code
rm -rf node_modules
npm install
Example Fix:
Remove .browserslistrc or browserslist: If you're keeping the configuration inside package.json, delete the .browserslistrc or browserslist file:

bash
Copy code
rm .browserslistrc
Keep configuration in package.json: Ensure your package.json has a browserslist entry like this:

json
Copy code
{
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
Or, keep .browserslistrc: Alternatively, delete the browserslist entry from package.json and keep the .browserslistrc file with the following contents:

markdown
Copy code

1%
last 2 versions
not dead

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

2 participants