CSS is a styling language used to beautify a web page.With CSS, a developer can make their website more attractive, user friendly. Try our curated libraries for different functionalities of CSS.

Popular New Releases in CSS

animate.css

v4.1.1

bulma

0.9.3

nerd-fonts

v2.2.0-RC: Workflow for building release candidate (WIP)

source-code-pro

Roman fonts version 2.038, Italic fonts version 1.058 and VAR fonts version 1.018 (OTF, TTF, WOFF, WOFF2)

pace

Version 1.2.4

Popular Libraries in CSS

animate.css

by animate-css doticoncssdoticon

star image 74293 doticonNOASSERTION

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

normalize.css

by necolas doticoncssdoticon

star image 45168 doticonMIT

A modern alternative to CSS resets

bulma

by jgthms doticoncssdoticon

star image 45040 doticonMIT

Modern CSS framework based on Flexbox

freecodecamp.cn

by FreeCodeCampChina doticoncssdoticon

star image 36627 doticonNOASSERTION

FCC China open source codebase and curriculum. Learn to code and help nonprofits.

nerd-fonts

by ryanoasis doticoncssdoticon

star image 33737 doticonNOASSERTION

Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more

hangzhou_house_knowledge

by houshanren doticoncssdoticon

star image 25626 doticon

2017年买房经历总结出来的买房购房知识分享给大家,希望对大家有所帮助。买房不易,且买且珍惜。Sharing the knowledge of buy an own house that according to the experience at hangzhou in 2017 to all the people. It's not easy to buy a own house, so I hope that it would be useful to everyone.

Hover

by IanLunn doticoncssdoticon

star image 25251 doticonNOASSERTION

A collection of CSS3 powered hover effects to be applied to links, buttons, logos, SVG, featured images and so on. Easily apply to your own elements, modify or just use for inspiration. Available in CSS, Sass, and LESS.

中文版 Apple 官方 Swift 教程《The Swift Programming Language》

Skeleton

by dhg doticoncssdoticon

star image 18379 doticonMIT

Skeleton: A Dead Simple, Responsive Boilerplate for Mobile-Friendly Development

Trending New libraries in CSS

50projects50days

by bradtraversy doticoncssdoticon

star image 8907 doticon

50+ mini web projects using HTML, CSS & JS

scaffold-eth

by scaffold-eth doticoncssdoticon

star image 6612 doticonMIT

🏗 forkable Ethereum dev stack focused on fast product iterations

98.css

by jdan doticoncssdoticon

star image 5958 doticonMIT

A design system for building faithful recreations of old UIs

windows11

by blueedgetechno doticoncssdoticon

star image 4719 doticonCC0-1.0

windows 11 in React 💻🌈⚡

Firefox-UI-Fix

by black7375 doticoncssdoticon

star image 3745 doticonMPL-2.0

🦊 I respect proton UI and aim to improve it.

macOS_Big_Sur_icons_replacements

by elrumo doticoncssdoticon

star image 3663 doticonGPL-3.0

Replacement icons for popular apps in the style of macOS Big Sur

the-economist-ebooks

by hehonghui doticoncssdoticon

star image 3629 doticon

经济学人(含音频)、纽约客、自然、新科学人、卫报、科学美国人、连线、大西洋月刊、新闻周刊、国家地理等英语杂志免费下载、订阅(kindle推送),支持epub、mobi、pdf格式, 每周更新. The Economist 、The New Yorker 、Nature、The Atlantic 、New Scientist、The Guardian、Scientific American、Wired、Newsweek magazines, free download and subscription for kindle, mobi、epub、pdf format.

missing-semester-cn.github.io

by missing-semester-cn doticoncssdoticon

star image 3443 doticonNOASSERTION

the CS missing semester Chinese version

handcalcs

by connorferster doticoncssdoticon

star image 3266 doticonApache-2.0

Python library for converting Python calculations into rendered latex.

Top Authors in CSS

1

webmural

827 Libraries

star icon1

2

dapdelivery

627 Libraries

star icon0

3

htmlacademy-javascript

585 Libraries

star icon5

4

js-tasks-ru

419 Libraries

star icon0

5

test1MC

290 Libraries

star icon1

6

angcuhoe

208 Libraries

star icon0

7

valekutce

199 Libraries

star icon0

8

stewilondanga

198 Libraries

star icon10

9

technext

181 Libraries

star icon288

10

mrmrs

171 Libraries

star icon12644

1

827 Libraries

star icon1

2

627 Libraries

star icon0

3

585 Libraries

star icon5

4

419 Libraries

star icon0

5

290 Libraries

star icon1

6

208 Libraries

star icon0

7

199 Libraries

star icon0

8

198 Libraries

star icon10

9

181 Libraries

star icon288

10

171 Libraries

star icon12644

Trending Kits in CSS

Here are some famous Vue Icons Libraries. Some of the Vue Icons Libraries' use cases include App Navigation, Dashboard Design, Data Visualization, UI/UX Design, and Iconography.


Vue icons libraries are collections of icons that can be used in Vue.js applications. These libraries typically include a variety of icons that can be used to represent various actions, elements, or concepts within an application. They can be used to enhance the user experience by providing visual cues that help guide the user through the application.


Let us have a look at these libraries in detail below.

feather

  • Designed to be modern, minimalistic, and lightweight.
  • Built with SVG, meaning they can be scaled up and down without losing any quality.
  • Icons are available in both SVG and web fonts, making them easy to use in a variety of projects.

ionicons

  • Created using vector graphics, meaning they scale well for responsive applications.
  • Accessible and WCAG 2.0 compliant, making them suitable for all types of web applications.
  • Designed for customization, allowing developers to change colors, sizes, and shapes of the icons.

flag-icons

  • Offers an extensive selection of flags from around the world in a variety of styles and sizes.
  • Includes alternative versions of some flags, such as a “defaced” version of the flag of the United States.
  • Includes a selection of generic icons, such as arrows and checkmarks, that can be used as additional visual indicators.

octicons

  • Specifically designed for GitHub, giving them a unique style that fits perfectly with the GitHub user interface.
  • Optimized for performance, ensuring that they won't slow down your website or application.
  • Completely open-source, with the source code available on GitHub.

devicon

  • Specifically designed for use in web development.
  • Icons are vector-based, meaning they look great at any size and can be easily scaled.
  • Updated regularly with new icons, so developers can keep up with the latest technology trends.

weather-icons

  • Unified set of symbols and icons for conveying weather conditions and phenomena.
  • Designed to be responsive, so it can scale to fit any screen size or device.
  • Icons for both the current and forecasted conditions, providing a comprehensive picture of the weather at a glance.

open-iconic

  • Only open source Vue icons library that offers a full suite of accessibility features.
  • One of the few Vue icons libraries that has a fully-documented API.
  • Provides a lightweight, fast, and reliable icon library that can be integrated into any project.

linearicons

  • Offers a searchable library of icons for quick access.
  • Icons are designed to be intuitive and easy to use.
  • Compatible with a wide range of frameworks, including Vue.js.

The CSS framework is a pre-prepared library that acts as a foundation for building. It consists of a set of predefined, reusable code snippets, styles, and components.


The developers can leverage it to streamline the design and development. CSS frameworks are particularly useful for creating responsive and aesthetically pleasing user interfaces.  

  

Benefits of Using CSS Frameworks:  

  1. Rapid Development: CSS frameworks provide a set of pre-built components and styles. This reduces the need to write repetitive code and speeds up the development.  
  2. Consistency: The Frameworks ensure a consistent design language across a website. It promotes a cohesive and professional appearance.  
  3. Responsive Design: Frameworks include grid systems and responsive utilities. This facilitates the creation of layouts. It adapts seamlessly to a variety of screen sizes and devices.  
  4. Cross-Browser Compatibility: Frameworks often come with tested styles. It minimizes the risk of compatibility issues.  
  5. Documentation and Community Support: Comprehensive documentation and a supportive community make it easier. It troubleshoots issues and stays up to date with best practices.  
  6. Time Efficiency: By leveraging pre-built styles and components. The developers can save time and meet project deadlines more efficiently.  
  7. Scalability: Frameworks are scalable. It allows easy expansion and modification of the codebase as the project evolves.  

  

In conclusion, the use of CSS frameworks is paramount in streamlining the web process. The adopting a CSS framework, developers can harness a wealth of pre-built styles. This not only expedites project timelines but also promotes code consistency. CSS frameworks provide a standardized design language, ensuring a cohesive visual identity. This not only enhances the professionalism of the website but also simplifies it.  

  

bootstrap  

  • Bootstrap is a popular open-source front-end framework developed by Twitter.  
  • It is a compilation of HTML, CSS, and JavaScript components that simplifies the process.  
  • Bootstrap uses a responsive grid system that allows you to create layouts with rows.


basscss  

  • Basscss is a lightweight and modular CSS toolkit. It provides a set of low-level utilities.  
  • Basscss includes responsive typography and layout classes, making it easy to create designs.  
  • Basscss is a standalone toolkit and doesn't rely on dependencies


tachyons  

  • Tachyons is a functional CSS framework that follows a similar philosophy to Basscss.  
  • It's designed to be a fast and efficient way to build user interfaces with a focus on simplicity.  
  • Tachyons provides a set of low-level utility classes that you can apply directly to HTML


Semantic-UI  

  • Semantic UI is a user interface framework that uses human-friendly HTML to create it.  
  • It aims to provide a clean and intuitive syntax for designing UI elements and layouts.  
  • Semantic UI utilizes semantic HTML elements and class names to describe the content. 


material-ui  

  • Material-UI is a popular React UI framework that implements Google's Material Design guidelines.  
  • Material-UI includes a comprehensive set of pre-designed React components that adhere to Google's.  
  • Material-UI provides a theming system. It allows you to customize the look and feel of an application.  


foundation-sites  

  • Foundation is a responsive front-end framework. It provides a collection of HTML and CSS.  
  • The foundation is popular for its flexibility, mobile-first approach, and robust grid system.  
  • Foundation includes a powerful grid system that allows you to create responsive.  


ant-design  

  • Ant Design is a renowned design system and React UI library that provides high-quality Reacts.  
  • Ant Design is a popular React UI library and design system developed by the team at Ant Group.  
  • Ant Design offers a comprehensive set of React components for building common users.  


pure  

  • Pure CSS is a combination of small, responsive CSS modules that helps in every web project.  
  • It has a minimal footprint and supports native HTML elements and UI components.  
  • Pure builds on Normalize.css and provides layout and styling for HTML elements.  


bulma  

  • Bulma is a modern CSS framework based on Flexbox.  
  • It provides a set of pre-designed CSS classes and components to help you quickly build it.  
  • Bulma is a lightweight framework that is easy to use and highly customizable.  

 

Skeleton  

  • Skeleton is a minimal and responsive CSS framework that provides a lightweight.  
  • Skeleton includes a simple and flexible 12-column grid system.  
  • This grid system makes it easy to create responsive layouts for various screen sizes.  


unocss  

  • UnoCSS is a modern CSS engine that provides the core functionalities of the CSS process.  
  • It is flexible, extensible, and lightweight, with zero dependencies.  
  • It is an atomic CSS engine providing functionalities via presets and developers.  


milligram  

  • Milligram is a minimalist CSS framework that provides a simple and clean set of styles.  
  • Milligram follows a minimalistic design philosophy, providing only the essential styles.  
  • Milligram includes a responsive grid system that allows you to create flexibly.  

  

spectre  

  • Spectre.css is a lightweight and responsive CSS framework. It helps in building modern CSS styles.  
  • It is easy to use, flexible, and minimalistic.  
  • Spectre provides a set of basic styles for common HTML elements.  

  

FAQ 

1. What are the best free and open-source CSS frameworks for web development?  

There are several excellent free and open-source CSS frameworks available for web development.  

  • Bootstrap  
  • Foundation  
  • Bulma  
  • Tailwind CSS  
  • Semantic UI  
  • Materialize CSS  

  

2. How do I choose a responsive and modern CSS framework?  

Choosing a responsive and modern CSS framework depends on various factors. It includes project requirements, development preferences, and design goals.  

  • Project Requirements  
  • Design Aesthetic  
  • Development Workflow  
  • Performance  
  • Community and Documentation  
  • Browser Compatibility  
  • Flexibility and Extensibility  
  • Testing  

  

3. How important is Material Design when choosing a CSS framework?  

The importance of Material Design when choosing a CSS framework depends on factors. It includes the project's goals, target audience, and design preferences. Material Design is a language developed by Google. That emphasizes a clean, modern, and consistent visual style across different platforms.  

  

4. What role does a CSS framework play in creating web interfaces?  

A CSS framework plays a crucial role in creating web interfaces. It provides a structured, efficient foundation for designing and styling websites.  

  • Consistent Styling  
  • Responsive Design  
  • Pre-Built Components  
  • Efficient Prototyping  
  • Cross-Browser Compatibility  
  • Ease of Maintenance  
  • Documentation and Support  
  • Scalability  
  • Time Efficiency  
  • Flexibility and Customization  

  

5. What advantages does the Bootstrap CSS framework offer over other options?  

Bootstrap is one of the most used CSS frameworks. It offers numerous advantages that contribute to its popularity.  

  • Comprehensive Set of Components  
  • Responsive Grid System  
  • Customizable Design  
  • Browser Compatibility  
  • Documentation  
  • JavaScript Components  
  • Fast Prototyping  
  • Theming Support  
  • Widely Adopted and Tested  

 

 

Weather forecasts are the need of the hour. There is a wide variety of end-users for weather updates. Weather warnings are important because they protect life and property. Weather forecasts based on temperature and precipitation are essential to agriculture and traders within commodity markets. Utility companies use temperature forecasts to estimate demand over the future. Daily, many use weather forecasts to determine what to wear on a given day. Since outdoor activities are severely affected by heavy rain, snow, and wind chill, these warnings can help plan these events and survive them. Listed below are some libraries that can be used to build a weather forecast system.

Trending Discussions on CSS

Error: useHref() may be used only in the context of a <Router> component. It works when I directly put the url as localhost:3000/experiences

ESlint - Error: Must use import to load ES Module

Create-React-App creates this <iframe> that prevents me from clicking or editing directly the app unless I delete it in the elements browswer editor

Switch' is not exported from 'react-router-dom'

Type Error: this.getOptions is not a function For style-loader

Module not found: Can't resolve 'swiper/css'

My project doesn't compile with optimization parameters after upgrading from angular 11 to angular 12

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in the package.json of a module in node_modules

Data path "" must NOT have additional properties(extractCss) in Angular 13 while upgrading project

Tailwind V3 causing TypeError: Cannot read property '500' of undefined

QUESTION

Error: useHref() may be used only in the context of a <Router> component. It works when I directly put the url as localhost:3000/experiences

Asked 2022-Mar-30 at 02:44

I have a navbar that is rendered in every route while the route changes on click.

./components/navbar.jsx

1import React, { Component } from 'react';
2import '../App.css';
3import { Link } from 'react-router-dom';
4
5
6
7class Navbar extends Component {
8    constructor(props) {
9        super(props);
10        this.state = {};
11    }
12    render() {
13        return (
14            <div id = 'navbar'>
15
16                <div className='name-head'>
17                    My Name
18                </div>
19            
20            
21                <div id = 'nav-links-container'>
22                    
23                    <Link to='/experiences'>
24                        <div className = 'nav-links'>
25                            Experiences
26                        </div>
27                    </Link>
28
29                    <div className = 'nav-links'>
30                        Projects
31                    </div>
32
33                    <div className = 'nav-links'>
34                        Skills
35                    </div>
36
37                    <div className = 'nav-links'>
38                        Resume
39                    </div>
40
41                </div>
42                
43            </div>
44        );
45    }
46}
47
48export default Navbar;
49

./components/experiences.jsx

1import React, { Component } from 'react';
2import '../App.css';
3import { Link } from 'react-router-dom';
4
5
6
7class Navbar extends Component {
8    constructor(props) {
9        super(props);
10        this.state = {};
11    }
12    render() {
13        return (
14            <div id = 'navbar'>
15
16                <div className='name-head'>
17                    My Name
18                </div>
19            
20            
21                <div id = 'nav-links-container'>
22                    
23                    <Link to='/experiences'>
24                        <div className = 'nav-links'>
25                            Experiences
26                        </div>
27                    </Link>
28
29                    <div className = 'nav-links'>
30                        Projects
31                    </div>
32
33                    <div className = 'nav-links'>
34                        Skills
35                    </div>
36
37                    <div className = 'nav-links'>
38                        Resume
39                    </div>
40
41                </div>
42                
43            </div>
44        );
45    }
46}
47
48export default Navbar;
49import React, { Component } from 'react';
50
51
52class Experiences extends Component {
53    
54    render() { 
55        return (
56            <div>
57                <h1>hi</h1>
58            </div>
59        );
60    }
61}
62 
63export default Experiences;
64

index.js

1import React, { Component } from 'react';
2import '../App.css';
3import { Link } from 'react-router-dom';
4
5
6
7class Navbar extends Component {
8    constructor(props) {
9        super(props);
10        this.state = {};
11    }
12    render() {
13        return (
14            <div id = 'navbar'>
15
16                <div className='name-head'>
17                    My Name
18                </div>
19            
20            
21                <div id = 'nav-links-container'>
22                    
23                    <Link to='/experiences'>
24                        <div className = 'nav-links'>
25                            Experiences
26                        </div>
27                    </Link>
28
29                    <div className = 'nav-links'>
30                        Projects
31                    </div>
32
33                    <div className = 'nav-links'>
34                        Skills
35                    </div>
36
37                    <div className = 'nav-links'>
38                        Resume
39                    </div>
40
41                </div>
42                
43            </div>
44        );
45    }
46}
47
48export default Navbar;
49import React, { Component } from 'react';
50
51
52class Experiences extends Component {
53    
54    render() { 
55        return (
56            <div>
57                <h1>hi</h1>
58            </div>
59        );
60    }
61}
62 
63export default Experiences;
64import React from 'react';
65import ReactDOM from 'react-dom';
66import './index.css';
67import reportWebVitals from './reportWebVitals';
68import Navbar from './components/Navbar';
69import Home from './components/Home';
70import Experiences from './components/experience';
71
72import {
73  BrowserRouter as Router, 
74  Routes, 
75  Route
76} from 'react-router-dom';
77
78
79
80ReactDOM.render(
81
82  <React.StrictMode>
83
84    <Navbar />
85
86    <Router>
87
88      <Routes>
89        <Route path="/" element={<Home />} />
90        <Route path="/experiences" element={<Experiences />} />
91      </Routes>
92
93    </Router>
94
95  </React.StrictMode>,
96
97  document.getElementById('root')
98);
99
100
101reportWebVitals();
102

The error doesn't come when I remove the <Link> from the experiences tag in navbar. There is a similar question posted here: Error: useHref() may be used only in the context of a <Router> component but doesn't help.

I'm using react router v6

ANSWER

Answered 2022-Feb-09 at 23:28
Issue

You are rendering the navbar outside the routing context. The Router isn't aware of what routes the links are attempting to link to that it is managing. The reason routing works when directly navigating to "/experiences" is because the Router is aware of the URL when the app mounts.

1import React, { Component } from 'react';
2import '../App.css';
3import { Link } from 'react-router-dom';
4
5
6
7class Navbar extends Component {
8    constructor(props) {
9        super(props);
10        this.state = {};
11    }
12    render() {
13        return (
14            &lt;div id = 'navbar'&gt;
15
16                &lt;div className='name-head'&gt;
17                    My Name
18                &lt;/div&gt;
19            
20            
21                &lt;div id = 'nav-links-container'&gt;
22                    
23                    &lt;Link to='/experiences'&gt;
24                        &lt;div className = 'nav-links'&gt;
25                            Experiences
26                        &lt;/div&gt;
27                    &lt;/Link&gt;
28
29                    &lt;div className = 'nav-links'&gt;
30                        Projects
31                    &lt;/div&gt;
32
33                    &lt;div className = 'nav-links'&gt;
34                        Skills
35                    &lt;/div&gt;
36
37                    &lt;div className = 'nav-links'&gt;
38                        Resume
39                    &lt;/div&gt;
40
41                &lt;/div&gt;
42                
43            &lt;/div&gt;
44        );
45    }
46}
47
48export default Navbar;
49import React, { Component } from 'react';
50
51
52class Experiences extends Component {
53    
54    render() { 
55        return (
56            &lt;div&gt;
57                &lt;h1&gt;hi&lt;/h1&gt;
58            &lt;/div&gt;
59        );
60    }
61}
62 
63export default Experiences;
64import React from 'react';
65import ReactDOM from 'react-dom';
66import './index.css';
67import reportWebVitals from './reportWebVitals';
68import Navbar from './components/Navbar';
69import Home from './components/Home';
70import Experiences from './components/experience';
71
72import {
73  BrowserRouter as Router, 
74  Routes, 
75  Route
76} from 'react-router-dom';
77
78
79
80ReactDOM.render(
81
82  &lt;React.StrictMode&gt;
83
84    &lt;Navbar /&gt;
85
86    &lt;Router&gt;
87
88      &lt;Routes&gt;
89        &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
90        &lt;Route path=&quot;/experiences&quot; element={&lt;Experiences /&gt;} /&gt;
91      &lt;/Routes&gt;
92
93    &lt;/Router&gt;
94
95  &lt;/React.StrictMode&gt;,
96
97  document.getElementById('root')
98);
99
100
101reportWebVitals();
102&lt;Navbar /&gt; // &lt;-- outside router!!
103
104&lt;Router&gt;
105  &lt;Routes&gt;
106    &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
107    &lt;Route path=&quot;/experiences&quot; element={&lt;Experiences /&gt;} /&gt;
108  &lt;/Routes&gt;
109&lt;/Router&gt;
110
Solution

Move it inside the routing context so the Router is aware and can manage routing correctly.

1import React, { Component } from 'react';
2import '../App.css';
3import { Link } from 'react-router-dom';
4
5
6
7class Navbar extends Component {
8    constructor(props) {
9        super(props);
10        this.state = {};
11    }
12    render() {
13        return (
14            &lt;div id = 'navbar'&gt;
15
16                &lt;div className='name-head'&gt;
17                    My Name
18                &lt;/div&gt;
19            
20            
21                &lt;div id = 'nav-links-container'&gt;
22                    
23                    &lt;Link to='/experiences'&gt;
24                        &lt;div className = 'nav-links'&gt;
25                            Experiences
26                        &lt;/div&gt;
27                    &lt;/Link&gt;
28
29                    &lt;div className = 'nav-links'&gt;
30                        Projects
31                    &lt;/div&gt;
32
33                    &lt;div className = 'nav-links'&gt;
34                        Skills
35                    &lt;/div&gt;
36
37                    &lt;div className = 'nav-links'&gt;
38                        Resume
39                    &lt;/div&gt;
40
41                &lt;/div&gt;
42                
43            &lt;/div&gt;
44        );
45    }
46}
47
48export default Navbar;
49import React, { Component } from 'react';
50
51
52class Experiences extends Component {
53    
54    render() { 
55        return (
56            &lt;div&gt;
57                &lt;h1&gt;hi&lt;/h1&gt;
58            &lt;/div&gt;
59        );
60    }
61}
62 
63export default Experiences;
64import React from 'react';
65import ReactDOM from 'react-dom';
66import './index.css';
67import reportWebVitals from './reportWebVitals';
68import Navbar from './components/Navbar';
69import Home from './components/Home';
70import Experiences from './components/experience';
71
72import {
73  BrowserRouter as Router, 
74  Routes, 
75  Route
76} from 'react-router-dom';
77
78
79
80ReactDOM.render(
81
82  &lt;React.StrictMode&gt;
83
84    &lt;Navbar /&gt;
85
86    &lt;Router&gt;
87
88      &lt;Routes&gt;
89        &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
90        &lt;Route path=&quot;/experiences&quot; element={&lt;Experiences /&gt;} /&gt;
91      &lt;/Routes&gt;
92
93    &lt;/Router&gt;
94
95  &lt;/React.StrictMode&gt;,
96
97  document.getElementById('root')
98);
99
100
101reportWebVitals();
102&lt;Navbar /&gt; // &lt;-- outside router!!
103
104&lt;Router&gt;
105  &lt;Routes&gt;
106    &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
107    &lt;Route path=&quot;/experiences&quot; element={&lt;Experiences /&gt;} /&gt;
108  &lt;/Routes&gt;
109&lt;/Router&gt;
110&lt;Router&gt;
111  &lt;Navbar /&gt;
112  &lt;Routes&gt;
113    &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
114    &lt;Route path=&quot;/experiences&quot; element={&lt;Experiences /&gt;} /&gt;
115  &lt;/Routes&gt;
116&lt;/Router&gt;
117

Source https://stackoverflow.com/questions/70220413

QUESTION

ESlint - Error: Must use import to load ES Module

Asked 2022-Mar-17 at 12:13

I am currently setting up a boilerplate with React, Typescript, styled components, webpack etc. and I am getting an error when trying to run eslint:

Error: Must use import to load ES Module

Here is a more verbose version of the error:

1/Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
2  0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
3require() of ES modules is not supported.
4require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains &quot;type&quot;: &quot;module&quot; which defines all .js files in that package scope as ES modules.
5Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove &quot;type&quot;: &quot;module&quot; from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
6

The error occurs in every single one of my .js and .ts/ .tsx files where I only use import or the file doesn't even have an import at all. I understand what the error is saying but I have no idea why it is being thrown when in fact I only use imports or even no imports at all in some files.

Here is my package.json where I trigger the linter from using npm run lint:eslint:quiet:

1/Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
2  0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
3require() of ES modules is not supported.
4require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains &quot;type&quot;: &quot;module&quot; which defines all .js files in that package scope as ES modules.
5Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove &quot;type&quot;: &quot;module&quot; from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
6{
7  &quot;name&quot;: &quot;my-react-boilerplate&quot;,
8  &quot;version&quot;: &quot;1.0.0&quot;,
9  &quot;description&quot;: &quot;&quot;,
10  &quot;main&quot;: &quot;index.tsx&quot;,
11  &quot;directories&quot;: {
12    &quot;test&quot;: &quot;test&quot;
13  },
14  &quot;engines&quot;: {
15    &quot;node&quot;: &quot;&gt;=14.0.0&quot;
16  },
17  &quot;type&quot;: &quot;module&quot;,
18  &quot;scripts&quot;: {
19    &quot;build&quot;: &quot;webpack --config webpack.prod.js&quot;,
20    &quot;dev&quot;: &quot;webpack serve --config webpack.dev.js&quot;,
21    &quot;lint&quot;: &quot;npm run typecheck &amp;&amp; npm run lint:css &amp;&amp; npm run lint:eslint:quiet&quot;,
22    &quot;lint:css&quot;: &quot;stylelint './src/**/*.{js,ts,tsx}'&quot;,
23    &quot;lint:eslint:quiet&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet&quot;,
24    &quot;lint:eslint&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern&quot;,
25    &quot;lint:eslint:fix&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix&quot;,
26    &quot;test&quot;: &quot;cross-env NODE_ENV=test jest --coverage&quot;,
27    &quot;test:watch&quot;: &quot;cross-env NODE_ENV=test jest --watchAll&quot;,
28    &quot;typecheck&quot;: &quot;tsc --noEmit&quot;,
29    &quot;precommit&quot;: &quot;npm run lint&quot;
30  },
31  &quot;lint-staged&quot;: {
32    &quot;*.{ts,tsx,js,jsx}&quot;: [
33      &quot;npm run lint:eslint:fix&quot;,
34      &quot;git add --force&quot;
35    ],
36    &quot;*.{md,json}&quot;: [
37      &quot;prettier --write&quot;,
38      &quot;git add --force&quot;
39    ]
40  },
41  &quot;husky&quot;: {
42    &quot;hooks&quot;: {
43      &quot;pre-commit&quot;: &quot;npx lint-staged &amp;&amp; npm run typecheck&quot;
44    }
45  },
46  &quot;resolutions&quot;: {
47    &quot;styled-components&quot;: &quot;^5&quot;
48  },
49  &quot;author&quot;: &quot;&quot;,
50  &quot;license&quot;: &quot;ISC&quot;,
51  &quot;devDependencies&quot;: {
52    &quot;@babel/core&quot;: &quot;^7.5.4&quot;,
53    &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.5.0&quot;,
54    &quot;@babel/preset-env&quot;: &quot;^7.5.4&quot;,
55    &quot;@babel/preset-react&quot;: &quot;^7.0.0&quot;,
56    &quot;@types/history&quot;: &quot;^4.7.6&quot;,
57    &quot;@types/react&quot;: &quot;^17.0.29&quot;,
58    &quot;@types/react-dom&quot;: &quot;^17.0.9&quot;,
59    &quot;@types/react-router&quot;: &quot;^5.1.17&quot;,
60    &quot;@types/react-router-dom&quot;: &quot;^5.1.5&quot;,
61    &quot;@types/styled-components&quot;: &quot;^5.1.15&quot;,
62    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.0.0&quot;,
63    &quot;babel-cli&quot;: &quot;^6.26.0&quot;,
64    &quot;babel-eslint&quot;: &quot;^10.0.2&quot;,
65    &quot;babel-loader&quot;: &quot;^8.0.0-beta.6&quot;,
66    &quot;babel-polyfill&quot;: &quot;^6.26.0&quot;,
67    &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
68    &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,
69    &quot;babel-preset-stage-2&quot;: &quot;^6.24.1&quot;,
70    &quot;clean-webpack-plugin&quot;: &quot;^4.0.0&quot;,
71    &quot;dotenv-webpack&quot;: &quot;^7.0.3&quot;,
72    &quot;error-overlay-webpack-plugin&quot;: &quot;^1.0.0&quot;,
73    &quot;eslint&quot;: &quot;^8.0.0&quot;,
74    &quot;eslint-config-airbnb&quot;: &quot;^18.2.0&quot;,
75    &quot;eslint-config-prettier&quot;: &quot;^8.3.0&quot;,
76    &quot;eslint-config-with-prettier&quot;: &quot;^6.0.0&quot;,
77    &quot;eslint-plugin-compat&quot;: &quot;^3.3.0&quot;,
78    &quot;eslint-plugin-import&quot;: &quot;^2.25.2&quot;,
79    &quot;eslint-plugin-jsx-a11y&quot;: &quot;^6.2.3&quot;,
80    &quot;eslint-plugin-prettier&quot;: &quot;^4.0.0&quot;,
81    &quot;eslint-plugin-react&quot;: &quot;^7.14.2&quot;,
82    &quot;eslint-plugin-react-hooks&quot;: &quot;^4.2.0&quot;,
83    &quot;extract-text-webpack-plugin&quot;: &quot;^3.0.2&quot;,
84    &quot;file-loader&quot;: &quot;^6.2.0&quot;,
85    &quot;html-webpack-plugin&quot;: &quot;^5.3.2&quot;,
86    &quot;husky&quot;: &quot;^7.0.2&quot;,
87    &quot;prettier&quot;: &quot;^2.4.1&quot;,
88    &quot;raw-loader&quot;: &quot;^4.0.2&quot;,
89    &quot;style-loader&quot;: &quot;^3.3.0&quot;,
90    &quot;stylelint&quot;: &quot;^13.13.1&quot;,
91    &quot;stylelint-config-recommended&quot;: &quot;^5.0.0&quot;,
92    &quot;stylelint-config-styled-components&quot;: &quot;^0.1.1&quot;,
93    &quot;stylelint-processor-styled-components&quot;: &quot;^1.10.0&quot;,
94    &quot;ts-loader&quot;: &quot;^9.2.6&quot;,
95    &quot;tslint&quot;: &quot;^6.1.3&quot;,
96    &quot;typescript&quot;: &quot;^4.4.4&quot;,
97    &quot;url-loader&quot;: &quot;^4.1.1&quot;,
98    &quot;webpack&quot;: &quot;^5.58.2&quot;,
99    &quot;webpack-cli&quot;: &quot;^4.2.0&quot;,
100    &quot;webpack-dev-server&quot;: &quot;^4.3.1&quot;,
101    &quot;webpack-merge&quot;: &quot;^5.3.0&quot;
102  },
103  &quot;dependencies&quot;: {
104    &quot;history&quot;: &quot;^4.10.0&quot;,
105    &quot;process&quot;: &quot;^0.11.10&quot;,
106    &quot;react&quot;: &quot;^17.0.1&quot;,
107    &quot;react-dom&quot;: &quot;^17.0.1&quot;,
108    &quot;react-router-dom&quot;: &quot;^5.2.0&quot;,
109    &quot;styled-components&quot;: &quot;^5.2.1&quot;
110  }
111}
112

Here is my .eslintrc file:

1/Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
2  0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
3require() of ES modules is not supported.
4require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains &quot;type&quot;: &quot;module&quot; which defines all .js files in that package scope as ES modules.
5Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove &quot;type&quot;: &quot;module&quot; from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
6{
7  &quot;name&quot;: &quot;my-react-boilerplate&quot;,
8  &quot;version&quot;: &quot;1.0.0&quot;,
9  &quot;description&quot;: &quot;&quot;,
10  &quot;main&quot;: &quot;index.tsx&quot;,
11  &quot;directories&quot;: {
12    &quot;test&quot;: &quot;test&quot;
13  },
14  &quot;engines&quot;: {
15    &quot;node&quot;: &quot;&gt;=14.0.0&quot;
16  },
17  &quot;type&quot;: &quot;module&quot;,
18  &quot;scripts&quot;: {
19    &quot;build&quot;: &quot;webpack --config webpack.prod.js&quot;,
20    &quot;dev&quot;: &quot;webpack serve --config webpack.dev.js&quot;,
21    &quot;lint&quot;: &quot;npm run typecheck &amp;&amp; npm run lint:css &amp;&amp; npm run lint:eslint:quiet&quot;,
22    &quot;lint:css&quot;: &quot;stylelint './src/**/*.{js,ts,tsx}'&quot;,
23    &quot;lint:eslint:quiet&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet&quot;,
24    &quot;lint:eslint&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern&quot;,
25    &quot;lint:eslint:fix&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix&quot;,
26    &quot;test&quot;: &quot;cross-env NODE_ENV=test jest --coverage&quot;,
27    &quot;test:watch&quot;: &quot;cross-env NODE_ENV=test jest --watchAll&quot;,
28    &quot;typecheck&quot;: &quot;tsc --noEmit&quot;,
29    &quot;precommit&quot;: &quot;npm run lint&quot;
30  },
31  &quot;lint-staged&quot;: {
32    &quot;*.{ts,tsx,js,jsx}&quot;: [
33      &quot;npm run lint:eslint:fix&quot;,
34      &quot;git add --force&quot;
35    ],
36    &quot;*.{md,json}&quot;: [
37      &quot;prettier --write&quot;,
38      &quot;git add --force&quot;
39    ]
40  },
41  &quot;husky&quot;: {
42    &quot;hooks&quot;: {
43      &quot;pre-commit&quot;: &quot;npx lint-staged &amp;&amp; npm run typecheck&quot;
44    }
45  },
46  &quot;resolutions&quot;: {
47    &quot;styled-components&quot;: &quot;^5&quot;
48  },
49  &quot;author&quot;: &quot;&quot;,
50  &quot;license&quot;: &quot;ISC&quot;,
51  &quot;devDependencies&quot;: {
52    &quot;@babel/core&quot;: &quot;^7.5.4&quot;,
53    &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.5.0&quot;,
54    &quot;@babel/preset-env&quot;: &quot;^7.5.4&quot;,
55    &quot;@babel/preset-react&quot;: &quot;^7.0.0&quot;,
56    &quot;@types/history&quot;: &quot;^4.7.6&quot;,
57    &quot;@types/react&quot;: &quot;^17.0.29&quot;,
58    &quot;@types/react-dom&quot;: &quot;^17.0.9&quot;,
59    &quot;@types/react-router&quot;: &quot;^5.1.17&quot;,
60    &quot;@types/react-router-dom&quot;: &quot;^5.1.5&quot;,
61    &quot;@types/styled-components&quot;: &quot;^5.1.15&quot;,
62    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.0.0&quot;,
63    &quot;babel-cli&quot;: &quot;^6.26.0&quot;,
64    &quot;babel-eslint&quot;: &quot;^10.0.2&quot;,
65    &quot;babel-loader&quot;: &quot;^8.0.0-beta.6&quot;,
66    &quot;babel-polyfill&quot;: &quot;^6.26.0&quot;,
67    &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
68    &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,
69    &quot;babel-preset-stage-2&quot;: &quot;^6.24.1&quot;,
70    &quot;clean-webpack-plugin&quot;: &quot;^4.0.0&quot;,
71    &quot;dotenv-webpack&quot;: &quot;^7.0.3&quot;,
72    &quot;error-overlay-webpack-plugin&quot;: &quot;^1.0.0&quot;,
73    &quot;eslint&quot;: &quot;^8.0.0&quot;,
74    &quot;eslint-config-airbnb&quot;: &quot;^18.2.0&quot;,
75    &quot;eslint-config-prettier&quot;: &quot;^8.3.0&quot;,
76    &quot;eslint-config-with-prettier&quot;: &quot;^6.0.0&quot;,
77    &quot;eslint-plugin-compat&quot;: &quot;^3.3.0&quot;,
78    &quot;eslint-plugin-import&quot;: &quot;^2.25.2&quot;,
79    &quot;eslint-plugin-jsx-a11y&quot;: &quot;^6.2.3&quot;,
80    &quot;eslint-plugin-prettier&quot;: &quot;^4.0.0&quot;,
81    &quot;eslint-plugin-react&quot;: &quot;^7.14.2&quot;,
82    &quot;eslint-plugin-react-hooks&quot;: &quot;^4.2.0&quot;,
83    &quot;extract-text-webpack-plugin&quot;: &quot;^3.0.2&quot;,
84    &quot;file-loader&quot;: &quot;^6.2.0&quot;,
85    &quot;html-webpack-plugin&quot;: &quot;^5.3.2&quot;,
86    &quot;husky&quot;: &quot;^7.0.2&quot;,
87    &quot;prettier&quot;: &quot;^2.4.1&quot;,
88    &quot;raw-loader&quot;: &quot;^4.0.2&quot;,
89    &quot;style-loader&quot;: &quot;^3.3.0&quot;,
90    &quot;stylelint&quot;: &quot;^13.13.1&quot;,
91    &quot;stylelint-config-recommended&quot;: &quot;^5.0.0&quot;,
92    &quot;stylelint-config-styled-components&quot;: &quot;^0.1.1&quot;,
93    &quot;stylelint-processor-styled-components&quot;: &quot;^1.10.0&quot;,
94    &quot;ts-loader&quot;: &quot;^9.2.6&quot;,
95    &quot;tslint&quot;: &quot;^6.1.3&quot;,
96    &quot;typescript&quot;: &quot;^4.4.4&quot;,
97    &quot;url-loader&quot;: &quot;^4.1.1&quot;,
98    &quot;webpack&quot;: &quot;^5.58.2&quot;,
99    &quot;webpack-cli&quot;: &quot;^4.2.0&quot;,
100    &quot;webpack-dev-server&quot;: &quot;^4.3.1&quot;,
101    &quot;webpack-merge&quot;: &quot;^5.3.0&quot;
102  },
103  &quot;dependencies&quot;: {
104    &quot;history&quot;: &quot;^4.10.0&quot;,
105    &quot;process&quot;: &quot;^0.11.10&quot;,
106    &quot;react&quot;: &quot;^17.0.1&quot;,
107    &quot;react-dom&quot;: &quot;^17.0.1&quot;,
108    &quot;react-router-dom&quot;: &quot;^5.2.0&quot;,
109    &quot;styled-components&quot;: &quot;^5.2.1&quot;
110  }
111}
112{
113  &quot;extends&quot;: [&quot;airbnb&quot;, &quot;prettier&quot;],
114  &quot;parser&quot;: &quot;babel-eslint&quot;,
115  &quot;plugins&quot;: [&quot;prettier&quot;, &quot;@typescript-eslint&quot;],
116  &quot;parserOptions&quot;: {
117    &quot;ecmaVersion&quot;: 8,
118    &quot;ecmaFeatures&quot;: {
119      &quot;experimentalObjectRestSpread&quot;: true,
120      &quot;impliedStrict&quot;: true,
121      &quot;classes&quot;: true
122    }
123  },
124  &quot;env&quot;: {
125    &quot;browser&quot;: true,
126    &quot;node&quot;: true,
127    &quot;jest&quot;: true
128  },
129  &quot;rules&quot;: {
130    &quot;arrow-body-style&quot;: [&quot;error&quot;, &quot;as-needed&quot;],
131    &quot;class-methods-use-this&quot;: 0,
132    &quot;react/jsx-filename-extension&quot;: 0,
133    &quot;global-require&quot;: 0,
134    &quot;react/destructuring-assignment&quot;: 0,
135    &quot;import/named&quot;: 2,
136    &quot;linebreak-style&quot;: 0,
137    &quot;import/no-dynamic-require&quot;: 0,
138    &quot;import/no-named-as-default&quot;: 0,
139    &quot;import/no-unresolved&quot;: 2,
140    &quot;import/prefer-default-export&quot;: 0,
141    &quot;semi&quot;: [2, &quot;always&quot;],
142    &quot;max-len&quot;: [
143      &quot;error&quot;,
144      {
145        &quot;code&quot;: 80,
146        &quot;ignoreUrls&quot;: true,
147        &quot;ignoreComments&quot;: true,
148        &quot;ignoreStrings&quot;: true,
149        &quot;ignoreTemplateLiterals&quot;: true
150      }
151    ],
152    &quot;new-cap&quot;: [
153      2,
154      {
155        &quot;capIsNew&quot;: false,
156        &quot;newIsCap&quot;: true
157      }
158    ],
159    &quot;no-param-reassign&quot;: 0,
160    &quot;no-shadow&quot;: 0,
161    &quot;no-tabs&quot;: 2,
162    &quot;no-underscore-dangle&quot;: 0,
163    &quot;react/forbid-prop-types&quot;: [
164      &quot;error&quot;,
165      {
166        &quot;forbid&quot;: [&quot;any&quot;]
167      }
168    ],
169    &quot;import/no-extraneous-dependencies&quot;: [&quot;error&quot;, { &quot;devDependencies&quot;: true }],
170    &quot;react/jsx-no-bind&quot;: [
171      &quot;error&quot;,
172      {
173        &quot;ignoreRefs&quot;: true,
174        &quot;allowArrowFunctions&quot;: true,
175        &quot;allowBind&quot;: false
176      }
177    ],
178    &quot;react/no-unknown-property&quot;: [
179      2,
180      {
181        &quot;ignore&quot;: [&quot;itemscope&quot;, &quot;itemtype&quot;, &quot;itemprop&quot;]
182      }
183    ]
184  }
185}
186

And i'm not sure if relevant but also my tsconfig.eslint.json file:

1/Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
2  0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
3require() of ES modules is not supported.
4require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains &quot;type&quot;: &quot;module&quot; which defines all .js files in that package scope as ES modules.
5Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove &quot;type&quot;: &quot;module&quot; from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
6{
7  &quot;name&quot;: &quot;my-react-boilerplate&quot;,
8  &quot;version&quot;: &quot;1.0.0&quot;,
9  &quot;description&quot;: &quot;&quot;,
10  &quot;main&quot;: &quot;index.tsx&quot;,
11  &quot;directories&quot;: {
12    &quot;test&quot;: &quot;test&quot;
13  },
14  &quot;engines&quot;: {
15    &quot;node&quot;: &quot;&gt;=14.0.0&quot;
16  },
17  &quot;type&quot;: &quot;module&quot;,
18  &quot;scripts&quot;: {
19    &quot;build&quot;: &quot;webpack --config webpack.prod.js&quot;,
20    &quot;dev&quot;: &quot;webpack serve --config webpack.dev.js&quot;,
21    &quot;lint&quot;: &quot;npm run typecheck &amp;&amp; npm run lint:css &amp;&amp; npm run lint:eslint:quiet&quot;,
22    &quot;lint:css&quot;: &quot;stylelint './src/**/*.{js,ts,tsx}'&quot;,
23    &quot;lint:eslint:quiet&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet&quot;,
24    &quot;lint:eslint&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern&quot;,
25    &quot;lint:eslint:fix&quot;: &quot;eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix&quot;,
26    &quot;test&quot;: &quot;cross-env NODE_ENV=test jest --coverage&quot;,
27    &quot;test:watch&quot;: &quot;cross-env NODE_ENV=test jest --watchAll&quot;,
28    &quot;typecheck&quot;: &quot;tsc --noEmit&quot;,
29    &quot;precommit&quot;: &quot;npm run lint&quot;
30  },
31  &quot;lint-staged&quot;: {
32    &quot;*.{ts,tsx,js,jsx}&quot;: [
33      &quot;npm run lint:eslint:fix&quot;,
34      &quot;git add --force&quot;
35    ],
36    &quot;*.{md,json}&quot;: [
37      &quot;prettier --write&quot;,
38      &quot;git add --force&quot;
39    ]
40  },
41  &quot;husky&quot;: {
42    &quot;hooks&quot;: {
43      &quot;pre-commit&quot;: &quot;npx lint-staged &amp;&amp; npm run typecheck&quot;
44    }
45  },
46  &quot;resolutions&quot;: {
47    &quot;styled-components&quot;: &quot;^5&quot;
48  },
49  &quot;author&quot;: &quot;&quot;,
50  &quot;license&quot;: &quot;ISC&quot;,
51  &quot;devDependencies&quot;: {
52    &quot;@babel/core&quot;: &quot;^7.5.4&quot;,
53    &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.5.0&quot;,
54    &quot;@babel/preset-env&quot;: &quot;^7.5.4&quot;,
55    &quot;@babel/preset-react&quot;: &quot;^7.0.0&quot;,
56    &quot;@types/history&quot;: &quot;^4.7.6&quot;,
57    &quot;@types/react&quot;: &quot;^17.0.29&quot;,
58    &quot;@types/react-dom&quot;: &quot;^17.0.9&quot;,
59    &quot;@types/react-router&quot;: &quot;^5.1.17&quot;,
60    &quot;@types/react-router-dom&quot;: &quot;^5.1.5&quot;,
61    &quot;@types/styled-components&quot;: &quot;^5.1.15&quot;,
62    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.0.0&quot;,
63    &quot;babel-cli&quot;: &quot;^6.26.0&quot;,
64    &quot;babel-eslint&quot;: &quot;^10.0.2&quot;,
65    &quot;babel-loader&quot;: &quot;^8.0.0-beta.6&quot;,
66    &quot;babel-polyfill&quot;: &quot;^6.26.0&quot;,
67    &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
68    &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,
69    &quot;babel-preset-stage-2&quot;: &quot;^6.24.1&quot;,
70    &quot;clean-webpack-plugin&quot;: &quot;^4.0.0&quot;,
71    &quot;dotenv-webpack&quot;: &quot;^7.0.3&quot;,
72    &quot;error-overlay-webpack-plugin&quot;: &quot;^1.0.0&quot;,
73    &quot;eslint&quot;: &quot;^8.0.0&quot;,
74    &quot;eslint-config-airbnb&quot;: &quot;^18.2.0&quot;,
75    &quot;eslint-config-prettier&quot;: &quot;^8.3.0&quot;,
76    &quot;eslint-config-with-prettier&quot;: &quot;^6.0.0&quot;,
77    &quot;eslint-plugin-compat&quot;: &quot;^3.3.0&quot;,
78    &quot;eslint-plugin-import&quot;: &quot;^2.25.2&quot;,
79    &quot;eslint-plugin-jsx-a11y&quot;: &quot;^6.2.3&quot;,
80    &quot;eslint-plugin-prettier&quot;: &quot;^4.0.0&quot;,
81    &quot;eslint-plugin-react&quot;: &quot;^7.14.2&quot;,
82    &quot;eslint-plugin-react-hooks&quot;: &quot;^4.2.0&quot;,
83    &quot;extract-text-webpack-plugin&quot;: &quot;^3.0.2&quot;,
84    &quot;file-loader&quot;: &quot;^6.2.0&quot;,
85    &quot;html-webpack-plugin&quot;: &quot;^5.3.2&quot;,
86    &quot;husky&quot;: &quot;^7.0.2&quot;,
87    &quot;prettier&quot;: &quot;^2.4.1&quot;,
88    &quot;raw-loader&quot;: &quot;^4.0.2&quot;,
89    &quot;style-loader&quot;: &quot;^3.3.0&quot;,
90    &quot;stylelint&quot;: &quot;^13.13.1&quot;,
91    &quot;stylelint-config-recommended&quot;: &quot;^5.0.0&quot;,
92    &quot;stylelint-config-styled-components&quot;: &quot;^0.1.1&quot;,
93    &quot;stylelint-processor-styled-components&quot;: &quot;^1.10.0&quot;,
94    &quot;ts-loader&quot;: &quot;^9.2.6&quot;,
95    &quot;tslint&quot;: &quot;^6.1.3&quot;,
96    &quot;typescript&quot;: &quot;^4.4.4&quot;,
97    &quot;url-loader&quot;: &quot;^4.1.1&quot;,
98    &quot;webpack&quot;: &quot;^5.58.2&quot;,
99    &quot;webpack-cli&quot;: &quot;^4.2.0&quot;,
100    &quot;webpack-dev-server&quot;: &quot;^4.3.1&quot;,
101    &quot;webpack-merge&quot;: &quot;^5.3.0&quot;
102  },
103  &quot;dependencies&quot;: {
104    &quot;history&quot;: &quot;^4.10.0&quot;,
105    &quot;process&quot;: &quot;^0.11.10&quot;,
106    &quot;react&quot;: &quot;^17.0.1&quot;,
107    &quot;react-dom&quot;: &quot;^17.0.1&quot;,
108    &quot;react-router-dom&quot;: &quot;^5.2.0&quot;,
109    &quot;styled-components&quot;: &quot;^5.2.1&quot;
110  }
111}
112{
113  &quot;extends&quot;: [&quot;airbnb&quot;, &quot;prettier&quot;],
114  &quot;parser&quot;: &quot;babel-eslint&quot;,
115  &quot;plugins&quot;: [&quot;prettier&quot;, &quot;@typescript-eslint&quot;],
116  &quot;parserOptions&quot;: {
117    &quot;ecmaVersion&quot;: 8,
118    &quot;ecmaFeatures&quot;: {
119      &quot;experimentalObjectRestSpread&quot;: true,
120      &quot;impliedStrict&quot;: true,
121      &quot;classes&quot;: true
122    }
123  },
124  &quot;env&quot;: {
125    &quot;browser&quot;: true,
126    &quot;node&quot;: true,
127    &quot;jest&quot;: true
128  },
129  &quot;rules&quot;: {
130    &quot;arrow-body-style&quot;: [&quot;error&quot;, &quot;as-needed&quot;],
131    &quot;class-methods-use-this&quot;: 0,
132    &quot;react/jsx-filename-extension&quot;: 0,
133    &quot;global-require&quot;: 0,
134    &quot;react/destructuring-assignment&quot;: 0,
135    &quot;import/named&quot;: 2,
136    &quot;linebreak-style&quot;: 0,
137    &quot;import/no-dynamic-require&quot;: 0,
138    &quot;import/no-named-as-default&quot;: 0,
139    &quot;import/no-unresolved&quot;: 2,
140    &quot;import/prefer-default-export&quot;: 0,
141    &quot;semi&quot;: [2, &quot;always&quot;],
142    &quot;max-len&quot;: [
143      &quot;error&quot;,
144      {
145        &quot;code&quot;: 80,
146        &quot;ignoreUrls&quot;: true,
147        &quot;ignoreComments&quot;: true,
148        &quot;ignoreStrings&quot;: true,
149        &quot;ignoreTemplateLiterals&quot;: true
150      }
151    ],
152    &quot;new-cap&quot;: [
153      2,
154      {
155        &quot;capIsNew&quot;: false,
156        &quot;newIsCap&quot;: true
157      }
158    ],
159    &quot;no-param-reassign&quot;: 0,
160    &quot;no-shadow&quot;: 0,
161    &quot;no-tabs&quot;: 2,
162    &quot;no-underscore-dangle&quot;: 0,
163    &quot;react/forbid-prop-types&quot;: [
164      &quot;error&quot;,
165      {
166        &quot;forbid&quot;: [&quot;any&quot;]
167      }
168    ],
169    &quot;import/no-extraneous-dependencies&quot;: [&quot;error&quot;, { &quot;devDependencies&quot;: true }],
170    &quot;react/jsx-no-bind&quot;: [
171      &quot;error&quot;,
172      {
173        &quot;ignoreRefs&quot;: true,
174        &quot;allowArrowFunctions&quot;: true,
175        &quot;allowBind&quot;: false
176      }
177    ],
178    &quot;react/no-unknown-property&quot;: [
179      2,
180      {
181        &quot;ignore&quot;: [&quot;itemscope&quot;, &quot;itemtype&quot;, &quot;itemprop&quot;]
182      }
183    ]
184  }
185}
186{
187  &quot;extends&quot;: &quot;./tsconfig.json&quot;,
188  &quot;include&quot;: [&quot;./src/**/*.ts&quot;, &quot;./src/**/*.tsx&quot;, &quot;./src/**/*.js&quot;],
189  &quot;exclude&quot;: [&quot;node_modules/**&quot;, &quot;build/**&quot;, &quot;coverage/**&quot;]
190}
191

Not sure if anyone has come across this before? Googling the error does not present any useful forums or raised bugs, most of them just state not to use require in your files which I am not.

ANSWER

Answered 2022-Mar-15 at 16:08

I think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like it doesn't support ES6 modules. Updating to the latest parser seems to work, at least for simple linting.

So, do this:

  • In package.json, update the line "babel-eslint": "^10.0.2", to "@babel/eslint-parser": "^7.5.4",. This works with the code above but it may be better to use the latest version, which at the time of writing is 7.16.3.
  • Run npm i from a terminal/command prompt in the folder
  • In .eslintrc, update the parser line "parser": "babel-eslint", to "parser": "@babel/eslint-parser",
  • In .eslintrc, add "requireConfigFile": false, to the parserOptions section (underneath "ecmaVersion": 8,) (I needed this or babel was looking for config files I don't have)
  • Run the command to lint a file

Then, for me with just your two configuration files, the error goes away and I get appropriate linting errors.

Source https://stackoverflow.com/questions/69554485

QUESTION

Create-React-App creates this &lt;iframe&gt; that prevents me from clicking or editing directly the app unless I delete it in the elements browswer editor

Asked 2022-Mar-17 at 00:14

I recently did a global install of create-react-app and am having an issue where sometimes, when I'm working on a project, instead of editing directly what I have rendered in , it creates this container around the entire app.

Upon further inspection it looks like it is an which is rendered in the browswer as this:

1&lt;iframe style=&quot;position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 2147483647;&quot;&gt;&lt;/iframe&gt;
2

I have screenshotted below what this ends up looking like in my app (the iframe is the orange text on the right), but it's super annoying and I've deleted the css props and cannot imagine what is causing this container around my app.

Has anyone else come across this? I have to delete this iframe to edit the elements directly from the browser but can't think why this is rendering each time I load the app in the browser.

enter image description here

ANSWER

Answered 2022-Jan-21 at 21:43

So after MUCH research and testing, I finally figured this out and I hope it can save anyone in the same situation I was in 😊

I have found two solutions that can solve this, one with a .env file that sometimes works, and the other solution is with css that I want to say always will solve this issue.

Fix #1: .env solution

In the root folder level (the same level as the .gitignore, package.json, README.md, yarn.lock, /src), create a .env file and include the following in it:

1&lt;iframe style=&quot;position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 2147483647;&quot;&gt;&lt;/iframe&gt;
2FAST_REFRESH=false
3

This sometimes works, but if this doesn't work after awhile, proceed to the second solution below.

Fix #2: App.css fix to disable pointer-events for iframe

This solution is what has saved me a bunch. Basically what this solution fixes is the wrapping iframe around the html files that exist in an app in the React.js template.

In your global styles file, add the following property to an iframe element: pointer-events: none. I then import this css file into my JSX page so that it will remove this iframe wrapper around the page. This will disable the iframe overlay and allow you to effectively click anywhere within the window frame.

1&lt;iframe style=&quot;position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 2147483647;&quot;&gt;&lt;/iframe&gt;
2FAST_REFRESH=false
3iframe {
4  pointer-events: none;
5}
6

Hopefully one of these solutions saves you hours of research and time 😊

Source https://stackoverflow.com/questions/70499543

QUESTION

Switch' is not exported from 'react-router-dom'

Asked 2022-Mar-01 at 09:07

In package.json file react-router-dom dependencies added. App component wrapped by BrowswerRouter , but when I wrap route by switch it says the following error Switch' is not exported from 'react-router-dom'. I deleted the package.json.lock ,node modules, installed npm again and npm install @babel/core --save. Still not working. I successfully wasted 6 hour for this. Can you please help me to fix this? why it's not importing?

Index.js

1import {BrowserRouter} from 'react-router-dom';
2
3ReactDOM.render(
4  &lt;BrowserRouter&gt;
5     &lt;App /&gt;
6  &lt;/BrowserRouter&gt;,
7  document.getElementById('root')
8);
9

App.js:

1import {BrowserRouter} from 'react-router-dom';
2
3ReactDOM.render(
4  &lt;BrowserRouter&gt;
5     &lt;App /&gt;
6  &lt;/BrowserRouter&gt;,
7  document.getElementById('root')
8);
9 import logo from './logo.svg';
10import './App.css';
11import React from 'react';
12import {Switch,Route,Link} from 'react-router-dom';
13import Home from './Home';
14class App extends React.Component {
15  componentDidMount(){
16    alert('mounting');
17  }
18  componentDidUpdate(){
19    alert('updated');
20  }
21 render(){
22  return (
23    
24    &lt;div className=&quot;App&quot;&gt;
25     
26    &lt;div&gt;
27      &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;
28    &lt;/div&gt;
29
30    &lt;hr /&gt;
31
32    &lt;Switch&gt;
33      &lt;Route exact path=&quot;/&quot;&gt;
34        &lt;Home/&gt;
35      &lt;/Route&gt;
36    &lt;/Switch&gt;
37 
38  &lt;/div&gt;
39 
40);
41 }
42}
43
44export default App;
45
46import React from 'react';
47
48    const Home = () =&gt; {
49    return &lt;h1&gt;Home&lt;/h1&gt;;
50  };
51  
52  export default Home;
53

package.json

1import {BrowserRouter} from 'react-router-dom';
2
3ReactDOM.render(
4  &lt;BrowserRouter&gt;
5     &lt;App /&gt;
6  &lt;/BrowserRouter&gt;,
7  document.getElementById('root')
8);
9 import logo from './logo.svg';
10import './App.css';
11import React from 'react';
12import {Switch,Route,Link} from 'react-router-dom';
13import Home from './Home';
14class App extends React.Component {
15  componentDidMount(){
16    alert('mounting');
17  }
18  componentDidUpdate(){
19    alert('updated');
20  }
21 render(){
22  return (
23    
24    &lt;div className=&quot;App&quot;&gt;
25     
26    &lt;div&gt;
27      &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;
28    &lt;/div&gt;
29
30    &lt;hr /&gt;
31
32    &lt;Switch&gt;
33      &lt;Route exact path=&quot;/&quot;&gt;
34        &lt;Home/&gt;
35      &lt;/Route&gt;
36    &lt;/Switch&gt;
37 
38  &lt;/div&gt;
39 
40);
41 }
42}
43
44export default App;
45
46import React from 'react';
47
48    const Home = () =&gt; {
49    return &lt;h1&gt;Home&lt;/h1&gt;;
50  };
51  
52  export default Home;
53&quot;dependencies&quot;: {
54    &quot;@babel/core&quot;: &quot;^7.16.0&quot;,
55    &quot;@testing-library/jest-dom&quot;: &quot;^5.11.4&quot;,
56    &quot;@testing-library/react&quot;: &quot;^11.1.0&quot;,
57    &quot;@testing-library/user-event&quot;: &quot;^12.1.10&quot;,
58    &quot;react&quot;: &quot;^17.0.2&quot;,
59    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
60    &quot;react-router&quot;: &quot;^6.0.0&quot;,
61    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;,
62    &quot;react-scripts&quot;: &quot;4.0.3&quot;,
63    &quot;web-vitals&quot;: &quot;^1.0.1&quot;
64  },
65

ANSWER

Answered 2021-Nov-04 at 18:10
Using Routes instead of Switch in react-router v6

You are using react-router-dom version 6, which replaced Switch with the Routes component

1import {BrowserRouter} from 'react-router-dom';
2
3ReactDOM.render(
4  &lt;BrowserRouter&gt;
5     &lt;App /&gt;
6  &lt;/BrowserRouter&gt;,
7  document.getElementById('root')
8);
9 import logo from './logo.svg';
10import './App.css';
11import React from 'react';
12import {Switch,Route,Link} from 'react-router-dom';
13import Home from './Home';
14class App extends React.Component {
15  componentDidMount(){
16    alert('mounting');
17  }
18  componentDidUpdate(){
19    alert('updated');
20  }
21 render(){
22  return (
23    
24    &lt;div className=&quot;App&quot;&gt;
25     
26    &lt;div&gt;
27      &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;
28    &lt;/div&gt;
29
30    &lt;hr /&gt;
31
32    &lt;Switch&gt;
33      &lt;Route exact path=&quot;/&quot;&gt;
34        &lt;Home/&gt;
35      &lt;/Route&gt;
36    &lt;/Switch&gt;
37 
38  &lt;/div&gt;
39 
40);
41 }
42}
43
44export default App;
45
46import React from 'react';
47
48    const Home = () =&gt; {
49    return &lt;h1&gt;Home&lt;/h1&gt;;
50  };
51  
52  export default Home;
53&quot;dependencies&quot;: {
54    &quot;@babel/core&quot;: &quot;^7.16.0&quot;,
55    &quot;@testing-library/jest-dom&quot;: &quot;^5.11.4&quot;,
56    &quot;@testing-library/react&quot;: &quot;^11.1.0&quot;,
57    &quot;@testing-library/user-event&quot;: &quot;^12.1.10&quot;,
58    &quot;react&quot;: &quot;^17.0.2&quot;,
59    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
60    &quot;react-router&quot;: &quot;^6.0.0&quot;,
61    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;,
62    &quot;react-scripts&quot;: &quot;4.0.3&quot;,
63    &quot;web-vitals&quot;: &quot;^1.0.1&quot;
64  },
65import {
66  BrowserRouter,
67  Routes, // instead of &quot;Switch&quot;
68  Route,
69} from &quot;react-router-dom&quot;;
70
71// ...
72
73    &lt;BrowserRouter&gt;
74      &lt;Routes&gt;
75        &lt;Route exact path=&quot;/&quot; element={&lt;Home /&gt;}&gt;
76          &lt;Home/&gt;
77        &lt;/Route&gt;
78      &lt;/Routes&gt;
79    &lt;/BrowserRouter&gt;
80

Note that you now also pass your component as the element prop instead of using children.

Source https://stackoverflow.com/questions/69843615

QUESTION

Type Error: this.getOptions is not a function For style-loader

Asked 2022-Feb-17 at 23:50

Problem

While using Storybook, I am running npm run storybook and getting the error below.

1ModuleBuildError: Module build failed (from ./node_modules/style-loader/dist/cjs.js):
2TypeError: this.getOptions is not a function
3

Background/Context

My goal is to get Storybook to be able to work with sass.

The setup is a simple one: I have scss files that get imported by the component file.

In looking up ways to accomplish this, I came across an addon to be able to do so, see this. Essentially, you can run npm i --save-dev @storybook/preset-scss style-loader css-loader sass-loader.

In doing so, I encountered my first error. It was the same error, but for sass-loader. This Stack Overflow thread helped me fix that error.

So, I guess in summary, I've tried:

  • Following along with the docs (linked above)
  • Following along with the Stack Overflow thread (linked above)

Relevant Dev Dependencies

1ModuleBuildError: Module build failed (from ./node_modules/style-loader/dist/cjs.js):
2TypeError: this.getOptions is not a function
3&quot;@storybook/preset-scss&quot;: &quot;^1.0.3&quot;,
4&quot;css-loader&quot;: &quot;^6.2.0&quot;,
5&quot;sass-loader&quot;: &quot;^10.1.1&quot;,
6&quot;style-loader&quot;: &quot;^3.2.1&quot;
7

Thanks ahead of time!

ANSWER

Answered 2021-Jul-29 at 17:17

Solution

After taking a step back, I realized that I could try out what I did to fix the sass-loader issue: downgrading major versions.

Steps

  • Downgraded style-loader 1 major version to 2.0.0: npm i style-loader@2.0.0
  • Then, as luck would have it, I ran into the same issue with css-loader
  • Downgraded css-loader 1 major version to 5.2.7: npm i css-loader@5.2.7

Summary

By downgrading all of the loaders one major version, I was able to get it to work.

Source https://stackoverflow.com/questions/68580273

QUESTION

Module not found: Can't resolve 'swiper/css'

Asked 2022-Feb-14 at 08:30

Swiper 7.0.5 swiper/css gives error Module not found: Can't resolve 'swiper/css'

1import { Swiper, SwiperSlide } from 'swiper/react';
2import 'swiper/css';
3function Test() {
4 return (
5  &lt;Swiper
6  spaceBetween={50}
7  slidesPerView={3}
8  onSlideChange={() =&gt; console.log('slide change')}
9  onSwiper={(swiper) =&gt; console.log(swiper)}
10&gt;
11  &lt;SwiperSlide&gt;Slide 1&lt;/SwiperSlide&gt;
12  &lt;SwiperSlide&gt;Slide 2&lt;/SwiperSlide&gt;
13  &lt;SwiperSlide&gt;Slide 3&lt;/SwiperSlide&gt;
14  &lt;SwiperSlide&gt;Slide 4&lt;/SwiperSlide&gt;
15  ...
16&lt;/Swiper&gt;
17);
18}
19
20 export default Test;
21

ANSWER

Answered 2021-Sep-28 at 07:01

after a whole day looking, I finally fixed it. remove swiper entirely and add version 6.8.4: npm:

1import { Swiper, SwiperSlide } from 'swiper/react';
2import 'swiper/css';
3function Test() {
4 return (
5  &lt;Swiper
6  spaceBetween={50}
7  slidesPerView={3}
8  onSlideChange={() =&gt; console.log('slide change')}
9  onSwiper={(swiper) =&gt; console.log(swiper)}
10&gt;
11  &lt;SwiperSlide&gt;Slide 1&lt;/SwiperSlide&gt;
12  &lt;SwiperSlide&gt;Slide 2&lt;/SwiperSlide&gt;
13  &lt;SwiperSlide&gt;Slide 3&lt;/SwiperSlide&gt;
14  &lt;SwiperSlide&gt;Slide 4&lt;/SwiperSlide&gt;
15  ...
16&lt;/Swiper&gt;
17);
18}
19
20 export default Test;
21npm install swiper@6.8.4
22

yarn:

1import { Swiper, SwiperSlide } from 'swiper/react';
2import 'swiper/css';
3function Test() {
4 return (
5  &lt;Swiper
6  spaceBetween={50}
7  slidesPerView={3}
8  onSlideChange={() =&gt; console.log('slide change')}
9  onSwiper={(swiper) =&gt; console.log(swiper)}
10&gt;
11  &lt;SwiperSlide&gt;Slide 1&lt;/SwiperSlide&gt;
12  &lt;SwiperSlide&gt;Slide 2&lt;/SwiperSlide&gt;
13  &lt;SwiperSlide&gt;Slide 3&lt;/SwiperSlide&gt;
14  &lt;SwiperSlide&gt;Slide 4&lt;/SwiperSlide&gt;
15  ...
16&lt;/Swiper&gt;
17);
18}
19
20 export default Test;
21npm install swiper@6.8.4
22yarn add swiper@6.8.4
23

then add this layout to your file and it should work:

1import { Swiper, SwiperSlide } from 'swiper/react';
2import 'swiper/css';
3function Test() {
4 return (
5  &lt;Swiper
6  spaceBetween={50}
7  slidesPerView={3}
8  onSlideChange={() =&gt; console.log('slide change')}
9  onSwiper={(swiper) =&gt; console.log(swiper)}
10&gt;
11  &lt;SwiperSlide&gt;Slide 1&lt;/SwiperSlide&gt;
12  &lt;SwiperSlide&gt;Slide 2&lt;/SwiperSlide&gt;
13  &lt;SwiperSlide&gt;Slide 3&lt;/SwiperSlide&gt;
14  &lt;SwiperSlide&gt;Slide 4&lt;/SwiperSlide&gt;
15  ...
16&lt;/Swiper&gt;
17);
18}
19
20 export default Test;
21npm install swiper@6.8.4
22yarn add swiper@6.8.4
23import { Swiper, SwiperSlide } from &quot;swiper/react&quot;;
24import 'swiper/swiper-bundle.min.css'
25import 'swiper/swiper.min.css'
26
27&lt;Swiper
28      spaceBetween={50}
29      slidesPerView={3}
30      centeredSlides
31      onSlideChange={() =&gt; console.log(&quot;slide change&quot;)}
32      onSwiper={swiper =&gt; console.log(swiper)}
33    &gt;
34      &lt;SwiperSlide&gt;Slide 1&lt;/SwiperSlide&gt;
35      &lt;SwiperSlide&gt;Slide 2&lt;/SwiperSlide&gt;
36      &lt;SwiperSlide&gt;Slide 3&lt;/SwiperSlide&gt;
37      &lt;SwiperSlide&gt;Slide 4&lt;/SwiperSlide&gt;
38    &lt;/Swiper&gt;
39

Source https://stackoverflow.com/questions/69154197

QUESTION

My project doesn't compile with optimization parameters after upgrading from angular 11 to angular 12

Asked 2022-Jan-31 at 19:50

I just upgraded an environment with nrwl from angular version 11 to 12 with two angular applications and several libraries. After update when I try to compile using optimization settings:

angular.json

1{
2 ....
3 &quot;optimization&quot;: {
4    &quot;scripts&quot;: true,
5    &quot;styles&quot;: {
6       &quot;minify&quot;: true,
7       &quot;inlineCritical&quot;: false
8     },
9     &quot;fonts&quot;: true
10  },
11}
12

It gives me the following error (sass and scss component files):

1{
2 ....
3 &quot;optimization&quot;: {
4    &quot;scripts&quot;: true,
5    &quot;styles&quot;: {
6       &quot;minify&quot;: true,
7       &quot;inlineCritical&quot;: false
8     },
9     &quot;fonts&quot;: true
10  },
11}
12/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass - Error: /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass from Css Minimizer
13Error: Transform failed with 1 error:
14error: Invalid version: &quot;15.2-15.3&quot;
15    at failureErrorWithLog (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1493:15)
16    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1282:29
17    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:629:9
18    at handleIncomingPacket (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:726:9)
19    at Socket.readFromStdout (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:596:7)
20    at Socket.emit (events.js:315:20)
21    at addChunk (_stream_readable.js:309:12)
22    at readableAddChunk (_stream_readable.js:284:9)
23    at Socket.Readable.push (_stream_readable.js:223:10)
24    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
25

Disabling styles.minify and fonts compiles without problems:

1{
2 ....
3 &quot;optimization&quot;: {
4    &quot;scripts&quot;: true,
5    &quot;styles&quot;: {
6       &quot;minify&quot;: true,
7       &quot;inlineCritical&quot;: false
8     },
9     &quot;fonts&quot;: true
10  },
11}
12/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass - Error: /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass from Css Minimizer
13Error: Transform failed with 1 error:
14error: Invalid version: &quot;15.2-15.3&quot;
15    at failureErrorWithLog (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1493:15)
16    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1282:29
17    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:629:9
18    at handleIncomingPacket (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:726:9)
19    at Socket.readFromStdout (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:596:7)
20    at Socket.emit (events.js:315:20)
21    at addChunk (_stream_readable.js:309:12)
22    at readableAddChunk (_stream_readable.js:284:9)
23    at Socket.Readable.push (_stream_readable.js:223:10)
24    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
25&quot;optimization&quot;: {
26    &quot;scripts&quot;: true,
27    &quot;styles&quot;: {
28       &quot;minify&quot;: false,
29       &quot;inlineCritical&quot;: false
30     },
31     &quot;fonts&quot;: false
32  },
33}
34

ANSWER

Answered 2022-Jan-31 at 19:50

Reason of the issue

It is expected browserslist to return an entry for each version ("safari 15.2", "safari 15.3") instead of a range ("safari 15.2-15.3"). So, this is just a bug in the parsing logic of Safari browser versions which needs to be corrected and will be done soon in fixed versions of Angular 12/Angular 13. Link to details is here.

IMPORTANT UPDATE:

This is fixed in v12.2.16 and v13.2.1, please update if you are experiencing this issue. Users on v11 shouldn't be affected. Link to details is here. If you can not/do not want to update for any reason, then one of the workarounds below can be used.

Workarounds:

Modify .browserslistrc

Add to .browserslistrc such lines:

1{
2 ....
3 &quot;optimization&quot;: {
4    &quot;scripts&quot;: true,
5    &quot;styles&quot;: {
6       &quot;minify&quot;: true,
7       &quot;inlineCritical&quot;: false
8     },
9     &quot;fonts&quot;: true
10  },
11}
12/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass - Error: /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass from Css Minimizer
13Error: Transform failed with 1 error:
14error: Invalid version: &quot;15.2-15.3&quot;
15    at failureErrorWithLog (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1493:15)
16    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1282:29
17    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:629:9
18    at handleIncomingPacket (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:726:9)
19    at Socket.readFromStdout (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:596:7)
20    at Socket.emit (events.js:315:20)
21    at addChunk (_stream_readable.js:309:12)
22    at readableAddChunk (_stream_readable.js:284:9)
23    at Socket.Readable.push (_stream_readable.js:223:10)
24    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
25&quot;optimization&quot;: {
26    &quot;scripts&quot;: true,
27    &quot;styles&quot;: {
28       &quot;minify&quot;: false,
29       &quot;inlineCritical&quot;: false
30     },
31     &quot;fonts&quot;: false
32  },
33}
34not ios_saf 15.2-15.3 # temporary solution to avoid build issues https://github.com/nrwl/nx/issues/8768
35not safari 15.2-15.3  # temporary solution to avoid build issues https://github.com/nrwl/nx/issues/8768
36

It has to come AFTER any mentions of ios_saf or safari. Otherwise, it doesn't work. Link to workaround is here.

Erase content of .browserslistrc

Erasing content of .browserslistrc helps to fix builds. Link to workaround is here.

Delete .browserslistrc

Deletion of .browserslistrc helps to fix builds. Link to workaround is here.

Install caniuse-lite

Add caniuse-lite package:

1{
2 ....
3 &quot;optimization&quot;: {
4    &quot;scripts&quot;: true,
5    &quot;styles&quot;: {
6       &quot;minify&quot;: true,
7       &quot;inlineCritical&quot;: false
8     },
9     &quot;fonts&quot;: true
10  },
11}
12/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass - Error: /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/libs/ui-share-components/src/lib/top-panel/top-panel/top-panel.component.sass from Css Minimizer
13Error: Transform failed with 1 error:
14error: Invalid version: &quot;15.2-15.3&quot;
15    at failureErrorWithLog (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1493:15)
16    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:1282:29
17    at /home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:629:9
18    at handleIncomingPacket (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:726:9)
19    at Socket.readFromStdout (/home/jose/WORK/Rental/REAL/APPS/angular-nx-ws/node_modules/@angular-devkit/build-angular/node_modules/esbuild/lib/main.js:596:7)
20    at Socket.emit (events.js:315:20)
21    at addChunk (_stream_readable.js:309:12)
22    at readableAddChunk (_stream_readable.js:284:9)
23    at Socket.Readable.push (_stream_readable.js:223:10)
24    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
25&quot;optimization&quot;: {
26    &quot;scripts&quot;: true,
27    &quot;styles&quot;: {
28       &quot;minify&quot;: false,
29       &quot;inlineCritical&quot;: false
30     },
31     &quot;fonts&quot;: false
32  },
33}
34not ios_saf 15.2-15.3 # temporary solution to avoid build issues https://github.com/nrwl/nx/issues/8768
35not safari 15.2-15.3  # temporary solution to avoid build issues https://github.com/nrwl/nx/issues/8768
36npm install caniuse-lite@1.0.30001303 --save-dev --save-exact
37

Link to workaround is here.

Source https://stackoverflow.com/questions/70910612

QUESTION

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in the package.json of a module in node_modules

Asked 2022-Jan-31 at 17:22

This is a React web app. When I run

1npm start
2

This error occurred

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24

This error only occurs when I run this on this specific computer, which I do not have superuser access to. It works on other computers.

For reference, this is ./node_modules/postcss-safe-parser/node_modules/postcss/package.json

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24{
25  "name": "postcss",
26  "version": "8.2.6",
27  "description": "Tool for transforming styles with JS plugins",
28  "engines": {
29    "node": "^10 || ^12 || &gt;=14"
30  },
31  "exports": {
32    ".": {
33      "require": "./lib/postcss.js",
34      "import": "./lib/postcss.mjs",
35      "types": "./lib/postcss.d.ts"
36    },
37    "./": "./"
38  },
39  "main": "./lib/postcss.js",
40  "types": "./lib/postcss.d.ts",
41  "keywords": [
42    "css",
43    "postcss",
44    "rework",
45    "preprocessor",
46    "parser",
47    "source map",
48    "transform",
49    "manipulation",
50    "transpiler"
51  ],
52  "funding": {
53    "type": "opencollective",
54    "url": "https://opencollective.com/postcss/"
55  },
56  "author": "Andrey Sitnik &lt;andrey@sitnik.ru&gt;",
57  "license": "MIT",
58  "homepage": "https://postcss.org/",
59  "repository": "postcss/postcss",
60  "dependencies": {
61    "colorette": "^1.2.1",
62    "nanoid": "^3.1.20",
63    "source-map": "^0.6.1"
64  },
65  "browser": {
66    "./lib/terminal-highlight": false,
67    "colorette": false,
68    "fs": false
69  }
70}

And this is what I get when I list the files in ./node_modules/postcss-safe-parser/node_modules/postcss/lib/

lgtd-lt-119-mbmt:frontend juliantc$ ls ./node_modules/postcss-safe-parser/node_modules/postcss/lib/

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24{
25  "name": "postcss",
26  "version": "8.2.6",
27  "description": "Tool for transforming styles with JS plugins",
28  "engines": {
29    "node": "^10 || ^12 || &gt;=14"
30  },
31  "exports": {
32    ".": {
33      "require": "./lib/postcss.js",
34      "import": "./lib/postcss.mjs",
35      "types": "./lib/postcss.d.ts"
36    },
37    "./": "./"
38  },
39  "main": "./lib/postcss.js",
40  "types": "./lib/postcss.d.ts",
41  "keywords": [
42    "css",
43    "postcss",
44    "rework",
45    "preprocessor",
46    "parser",
47    "source map",
48    "transform",
49    "manipulation",
50    "transpiler"
51  ],
52  "funding": {
53    "type": "opencollective",
54    "url": "https://opencollective.com/postcss/"
55  },
56  "author": "Andrey Sitnik &lt;andrey@sitnik.ru&gt;",
57  "license": "MIT",
58  "homepage": "https://postcss.org/",
59  "repository": "postcss/postcss",
60  "dependencies": {
61    "colorette": "^1.2.1",
62    "nanoid": "^3.1.20",
63    "source-map": "^0.6.1"
64  },
65  "browser": {
66    "./lib/terminal-highlight": false,
67    "colorette": false,
68    "fs": false
69  }
70}at-rule.d.ts        css-syntax-error.d.ts   input.d.ts      map-generator.js    postcss.d.ts        processor.js        rule.js         tokenize.js
71at-rule.js      css-syntax-error.js input.js        node.d.ts       postcss.js      result.d.ts     stringifier.js      warn-once.js
72comment.d.ts        declaration.d.ts    lazy-result.d.ts    node.js         postcss.mjs     result.js       stringify.d.ts      warning.d.ts
73comment.js      declaration.js      lazy-result.js      parse.d.ts      previous-map.d.ts   root.d.ts       stringify.js        warning.js
74container.d.ts      fromJSON.d.ts       list.d.ts       parse.js        previous-map.js     root.js         symbols.js
75container.js        fromJSON.js     list.js         parser.js       processor.d.ts      rule.d.ts       terminal-highlight.js
76

ANSWER

Answered 2021-Nov-13 at 18:36

I am also stuck with the same problem because I installed the latest version of Node.js (v17.0.1).

Just go for node.js v14.18.1 and remove the latest version just use the stable version v14.18.1

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24{
25  "name": "postcss",
26  "version": "8.2.6",
27  "description": "Tool for transforming styles with JS plugins",
28  "engines": {
29    "node": "^10 || ^12 || &gt;=14"
30  },
31  "exports": {
32    ".": {
33      "require": "./lib/postcss.js",
34      "import": "./lib/postcss.mjs",
35      "types": "./lib/postcss.d.ts"
36    },
37    "./": "./"
38  },
39  "main": "./lib/postcss.js",
40  "types": "./lib/postcss.d.ts",
41  "keywords": [
42    "css",
43    "postcss",
44    "rework",
45    "preprocessor",
46    "parser",
47    "source map",
48    "transform",
49    "manipulation",
50    "transpiler"
51  ],
52  "funding": {
53    "type": "opencollective",
54    "url": "https://opencollective.com/postcss/"
55  },
56  "author": "Andrey Sitnik &lt;andrey@sitnik.ru&gt;",
57  "license": "MIT",
58  "homepage": "https://postcss.org/",
59  "repository": "postcss/postcss",
60  "dependencies": {
61    "colorette": "^1.2.1",
62    "nanoid": "^3.1.20",
63    "source-map": "^0.6.1"
64  },
65  "browser": {
66    "./lib/terminal-highlight": false,
67    "colorette": false,
68    "fs": false
69  }
70}at-rule.d.ts        css-syntax-error.d.ts   input.d.ts      map-generator.js    postcss.d.ts        processor.js        rule.js         tokenize.js
71at-rule.js      css-syntax-error.js input.js        node.d.ts       postcss.js      result.d.ts     stringifier.js      warn-once.js
72comment.d.ts        declaration.d.ts    lazy-result.d.ts    node.js         postcss.mjs     result.js       stringify.d.ts      warning.d.ts
73comment.js      declaration.js      lazy-result.js      parse.d.ts      previous-map.d.ts   root.d.ts       stringify.js        warning.js
74container.d.ts      fromJSON.d.ts       list.d.ts       parse.js        previous-map.js     root.js         symbols.js
75container.js        fromJSON.js     list.js         parser.js       processor.d.ts      rule.d.ts       terminal-highlight.js
76nvm uninstall &lt;version&gt;
77

OR

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24{
25  "name": "postcss",
26  "version": "8.2.6",
27  "description": "Tool for transforming styles with JS plugins",
28  "engines": {
29    "node": "^10 || ^12 || &gt;=14"
30  },
31  "exports": {
32    ".": {
33      "require": "./lib/postcss.js",
34      "import": "./lib/postcss.mjs",
35      "types": "./lib/postcss.d.ts"
36    },
37    "./": "./"
38  },
39  "main": "./lib/postcss.js",
40  "types": "./lib/postcss.d.ts",
41  "keywords": [
42    "css",
43    "postcss",
44    "rework",
45    "preprocessor",
46    "parser",
47    "source map",
48    "transform",
49    "manipulation",
50    "transpiler"
51  ],
52  "funding": {
53    "type": "opencollective",
54    "url": "https://opencollective.com/postcss/"
55  },
56  "author": "Andrey Sitnik &lt;andrey@sitnik.ru&gt;",
57  "license": "MIT",
58  "homepage": "https://postcss.org/",
59  "repository": "postcss/postcss",
60  "dependencies": {
61    "colorette": "^1.2.1",
62    "nanoid": "^3.1.20",
63    "source-map": "^0.6.1"
64  },
65  "browser": {
66    "./lib/terminal-highlight": false,
67    "colorette": false,
68    "fs": false
69  }
70}at-rule.d.ts        css-syntax-error.d.ts   input.d.ts      map-generator.js    postcss.d.ts        processor.js        rule.js         tokenize.js
71at-rule.js      css-syntax-error.js input.js        node.d.ts       postcss.js      result.d.ts     stringifier.js      warn-once.js
72comment.d.ts        declaration.d.ts    lazy-result.d.ts    node.js         postcss.mjs     result.js       stringify.d.ts      warning.d.ts
73comment.js      declaration.js      lazy-result.js      parse.d.ts      previous-map.d.ts   root.d.ts       stringify.js        warning.js
74container.d.ts      fromJSON.d.ts       list.d.ts       parse.js        previous-map.js     root.js         symbols.js
75container.js        fromJSON.js     list.js         parser.js       processor.d.ts      rule.d.ts       terminal-highlight.js
76nvm uninstall &lt;version&gt;
77nvm uninstall v17.0.1
78

then install the LTS one which is v14.18.1

1npm start
2&gt; dataflow@0.1.0 start
3&gt; react-scripts start
4
5node:internal/modules/cjs/loader:488
6      throw e;
7  ^
8
9Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by &quot;exports&quot; in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
10    at new NodeError (node:internal/errors:371:5)
11    at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
12    at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
13    at resolveExports (node:internal/modules/cjs/loader:482:36)
14    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
15    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
16    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
17    at Module.require (node:internal/modules/cjs/loader:999:19)
18    at require (node:internal/modules/cjs/helpers:102:18)
19    at Object.&lt;anonymous&gt; (/Users/juliantc/Desktop/ai-    studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
20  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
21}
22
23Node.js v17.0.1
24{
25  "name": "postcss",
26  "version": "8.2.6",
27  "description": "Tool for transforming styles with JS plugins",
28  "engines": {
29    "node": "^10 || ^12 || &gt;=14"
30  },
31  "exports": {
32    ".": {
33      "require": "./lib/postcss.js",
34      "import": "./lib/postcss.mjs",
35      "types": "./lib/postcss.d.ts"
36    },
37    "./": "./"
38  },
39  "main": "./lib/postcss.js",
40  "types": "./lib/postcss.d.ts",
41  "keywords": [
42    "css",
43    "postcss",
44    "rework",
45    "preprocessor",
46    "parser",
47    "source map",
48    "transform",
49    "manipulation",
50    "transpiler"
51  ],
52  "funding": {
53    "type": "opencollective",
54    "url": "https://opencollective.com/postcss/"
55  },
56  "author": "Andrey Sitnik &lt;andrey@sitnik.ru&gt;",
57  "license": "MIT",
58  "homepage": "https://postcss.org/",
59  "repository": "postcss/postcss",
60  "dependencies": {
61    "colorette": "^1.2.1",
62    "nanoid": "^3.1.20",
63    "source-map": "^0.6.1"
64  },
65  "browser": {
66    "./lib/terminal-highlight": false,
67    "colorette": false,
68    "fs": false
69  }
70}at-rule.d.ts        css-syntax-error.d.ts   input.d.ts      map-generator.js    postcss.d.ts        processor.js        rule.js         tokenize.js
71at-rule.js      css-syntax-error.js input.js        node.d.ts       postcss.js      result.d.ts     stringifier.js      warn-once.js
72comment.d.ts        declaration.d.ts    lazy-result.d.ts    node.js         postcss.mjs     result.js       stringify.d.ts      warning.d.ts
73comment.js      declaration.js      lazy-result.js      parse.d.ts      previous-map.d.ts   root.d.ts       stringify.js        warning.js
74container.d.ts      fromJSON.d.ts       list.d.ts       parse.js        previous-map.js     root.js         symbols.js
75container.js        fromJSON.js     list.js         parser.js       processor.d.ts      rule.d.ts       terminal-highlight.js
76nvm uninstall &lt;version&gt;
77nvm uninstall v17.0.1
78nvm install --lts
79

This worked for me.

Source https://stackoverflow.com/questions/69693907

QUESTION

Data path &quot;&quot; must NOT have additional properties(extractCss) in Angular 13 while upgrading project

Asked 2022-Jan-27 at 14:41

I am facing an issue while upgrading my project from angular 8.2.1 to angular 13 version.

After a successful upgrade while preparing a build it is giving me the following error.

1Data path &quot;&quot; must NOT have additional properties(extractCss).
2

I already renamed styleext with style in the angular.json file, but still not able to find the root cause for this error.

angular.json file is as follows.

1Data path &quot;&quot; must NOT have additional properties(extractCss).
2  {
3  &quot;$schema&quot;: &quot;./node_modules/@angular/cli/lib/config/schema.json&quot;,
4  &quot;version&quot;: 1,
5  &quot;newProjectRoot&quot;: &quot;projects&quot;,
6  &quot;projects&quot;: {
7    &quot;qiwkCollaborator&quot;: {
8      &quot;projectType&quot;: &quot;application&quot;,
9      &quot;schematics&quot;: {
10        &quot;@schematics/angular:component&quot;: {
11          &quot;style&quot;: &quot;scss&quot;
12        }
13      },
14      &quot;root&quot;: &quot;&quot;,
15      &quot;sourceRoot&quot;: &quot;src&quot;,
16      &quot;prefix&quot;: &quot;app&quot;,
17      &quot;architect&quot;: {
18        &quot;build&quot;: {
19
20        /*  &quot;configurations&quot;: {
21            &quot;fr&quot;: {
22            &quot;aot&quot;: true,
23            &quot;outputPath&quot;: &quot;dist/qwikCollaborator/fr/&quot;,
24            &quot;i18nFile&quot;: &quot;src/translate/messages.fr.xlf&quot;,      
25            &quot;i18nFormat&quot;: &quot;xlf&quot;,      
26            &quot;i18nLocale&quot;: &quot;fr&quot;,      
27            &quot;i18nMissingTranslation&quot;: &quot;error&quot;    
28             },
29             &quot;en&quot;: {
30            &quot;aot&quot;: true,
31            &quot;outputPath&quot;: &quot;dist/qwikCollaborator/en/&quot;,
32            &quot;i18nFile&quot;: &quot;src/translate/messages.en.xlf&quot;,      
33            &quot;i18nFormat&quot;: &quot;xlf&quot;,      
34            &quot;i18nLocale&quot;: &quot;en&quot;,      
35            &quot;i18nMissingTranslation&quot;: &quot;error&quot;    
36             }  
37           },*/
38          &quot;builder&quot;: &quot;@angular-devkit/build-angular:browser&quot;,
39          &quot;options&quot;: {
40            &quot;outputPath&quot;: &quot;dist/qiwkCollaborator&quot;,
41            &quot;index&quot;: &quot;src/index.html&quot;,
42            &quot;main&quot;: &quot;src/main.ts&quot;,
43            &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
44            &quot;tsConfig&quot;: &quot;tsconfig.app.json&quot;,
45            &quot;aot&quot;: false,
46            &quot;assets&quot;: [
47              &quot;src/favicon.ico&quot;,
48              &quot;src/assets&quot;
49            ],
50            &quot;styles&quot;: [
51              &quot;src/styles.scss&quot;,
52              &quot;src/assets/css/custom-mobile.css&quot;,
53              &quot;src/assets/css/custom.css&quot;
54            ],
55            &quot;scripts&quot;: [
56              &quot;node_modules/jquery/dist/jquery.min.js&quot;,
57              &quot;src/assets/js/qwikCollaborator.js&quot;
58            ]
59          },
60          &quot;configurations&quot;: {
61          &quot;es5&quot;: {
62        &quot;tsConfig&quot;: &quot;./tsconfig.es5.json&quot;
63      },
64            &quot;production&quot;: {
65              &quot;fileReplacements&quot;: [
66                {
67                  &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
68                  &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;
69                }
70              ],
71              &quot;optimization&quot;: true,
72              &quot;outputHashing&quot;: &quot;all&quot;,
73              &quot;sourceMap&quot;: false,
74              &quot;extractCss&quot;: true,
75              &quot;namedChunks&quot;: false,
76              &quot;aot&quot;: true,
77              &quot;extractLicenses&quot;: true,
78              &quot;vendorChunk&quot;: false,
79              &quot;buildOptimizer&quot;: true,
80              &quot;budgets&quot;: [
81                {
82                  &quot;type&quot;: &quot;initial&quot;,
83                  &quot;maximumWarning&quot;: &quot;2mb&quot;,
84                  &quot;maximumError&quot;: &quot;5mb&quot;
85                },
86                {
87                  &quot;type&quot;: &quot;anyComponentStyle&quot;,
88                  &quot;maximumWarning&quot;: &quot;6kb&quot;,
89                  &quot;maximumError&quot;: &quot;10kb&quot;
90                }
91              ]
92            }
93          }
94        },
95        &quot;serve&quot;: {
96         /*  &quot;configurations&quot;: {
97            &quot;fr&quot;: {
98            &quot;browserTarget&quot;: &quot;qwikCollaborator:build:fr&quot; 
99            },
100            &quot;en&quot;: {
101            &quot;browserTarget&quot;: &quot;qwikCollaborator:build:en&quot; 
102            } ,
103            },*/
104          &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,
105          &quot;options&quot;: {
106            &quot;browserTarget&quot;: &quot;qiwkCollaborator:build&quot;
107          },
108         
109          &quot;configurations&quot;: {
110          &quot;es5&quot;: {
111        &quot;browserTarget&quot;: &quot;qiwkCollaborator:build:es5&quot;
112      },
113            &quot;production&quot;: {
114              &quot;browserTarget&quot;: &quot;qiwkCollaborator:build:es5&quot;
115            }
116          }
117        },
118        &quot;extract-i18n&quot;: {
119          &quot;builder&quot;: &quot;@angular-devkit/build-angular:extract-i18n&quot;,
120          &quot;options&quot;: {
121            &quot;browserTarget&quot;: &quot;qiwkCollaborator:build&quot;
122          }
123        },
124        &quot;test&quot;: {
125          &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;,
126          &quot;options&quot;: {
127            &quot;main&quot;: &quot;src/test.ts&quot;,
128            &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
129            &quot;tsConfig&quot;: &quot;tsconfig.spec.json&quot;,
130            &quot;karmaConfig&quot;: &quot;karma.conf.js&quot;,
131            &quot;assets&quot;: [
132              &quot;src/favicon.ico&quot;,
133              &quot;src/assets&quot;
134            ],
135            &quot;styles&quot;: [
136              &quot;src/styles.scss&quot;
137            ],
138            &quot;scripts&quot;: [&quot;../node_modules/jspdf/dist/jspdf.min.js&quot;]
139          }
140        },
141        &quot;lint&quot;: {
142          &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
143          &quot;options&quot;: {
144            &quot;tsConfig&quot;: [
145              &quot;tsconfig.app.json&quot;,
146              &quot;tsconfig.spec.json&quot;,
147              &quot;e2e/tsconfig.json&quot;
148            ],
149            &quot;exclude&quot;: [
150              &quot;**/node_modules/**&quot;
151            ]
152          }
153        },
154        &quot;e2e&quot;: {
155          &quot;builder&quot;: &quot;@angular-devkit/build-angular:protractor&quot;,
156          &quot;options&quot;: {
157            &quot;protractorConfig&quot;: &quot;e2e/protractor.conf.js&quot;,
158            &quot;devServerTarget&quot;: &quot;qiwkCollaborator:serve&quot;
159          },
160          &quot;configurations&quot;: {
161            &quot;production&quot;: {
162              &quot;devServerTarget&quot;: &quot;qiwkCollaborator:serve:production&quot;
163            }
164          }
165        }
166      }
167    }},
168  &quot;defaultProject&quot;: &quot;qiwkCollaborator&quot;
169}
170

How to get rid of this additional property?

can anyone help me with this?

thanks in advance!

ANSWER

Answered 2021-Dec-14 at 12:45

Just remove the "extractCss": true from your production environment, it will resolve the problem.

The reason about it is extractCss is deprecated, and it's value is true by default. See more here: Extracting CSS into JS with Angular 11 (deprecated extractCss)

Source https://stackoverflow.com/questions/70344098

QUESTION

Tailwind V3 causing TypeError: Cannot read property '500' of undefined

Asked 2022-Jan-26 at 20:02

I recently tried to upgrade my project to tailwind css and I'm getting this error

Console Error

this is my tailwind config

1 module.exports = {
2      mode: &quot;jit&quot;,
3      purge: [&quot;./pages/**/*.{js,ts,jsx,tsx}&quot;, &quot;./components/**/*.{js,ts,jsx,tsx}&quot;],
4      darkMode: &quot;class&quot;, // or 'media' or 'class'
5      theme: {
6        extend: {
7          colors: {
8            secondaryDark: &quot;#171A1A&quot;,
9            primaryDark: &quot;#090A0A&quot;,
10            neonOrange: &quot;#FF9933&quot;,
11            redditRed: &quot;#FF5700&quot;,
12            cardGradientPrimary: &quot;#ff930f&quot;,
13            cardGradientSecondary: &quot;#fff95b&quot;,
14          },
15        },
16      },
17      variants: {
18        extend: {},
19      },
20      plugins: [require(&quot;@tailwindcss/forms&quot;)],
21    };
22

ANSWER

Answered 2021-Dec-11 at 03:50

I have the same issue after upgrade to tailwind v3 and fixed it by update @tailwindcss/forms to 0.4.0

Source https://stackoverflow.com/questions/70304366

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in CSS

Share this Page

share link

Get latest updates on CSS