yarn create react-app
yarn add react-select
I created a react app using create-react-app, and it worked fine.
Then I wanted to use react-select, so I installed it with yarn, added an import statement like import Select from "react-select/src/Select";
I got this error:
Failed to pile.
./node_modules/react-select/src/Select.js
SyntaxError: ~~~~\node_modules\react-select\src\Select.js: Unexpected token, expected "," (3:32)
1 | // @flow
2 |
> 3 | import React, { Component, type ElementRef, type Node } from 'react';
| ^
4 | import memoizeOne from 'memoize-one';
5 | import { MenuPlacer } from './ponents/Menu';
6 | import isEqual from './internal/react-fast-pare';
I can see the type
keyword is causing the issue and suspect it has to do with something named flow
which seems a static type checker.
What should I do to make it work?
yarn create react-app
yarn add react-select
I created a react app using create-react-app, and it worked fine.
Then I wanted to use react-select, so I installed it with yarn, added an import statement like import Select from "react-select/src/Select";
I got this error:
Failed to pile.
./node_modules/react-select/src/Select.js
SyntaxError: ~~~~\node_modules\react-select\src\Select.js: Unexpected token, expected "," (3:32)
1 | // @flow
2 |
> 3 | import React, { Component, type ElementRef, type Node } from 'react';
| ^
4 | import memoizeOne from 'memoize-one';
5 | import { MenuPlacer } from './ponents/Menu';
6 | import isEqual from './internal/react-fast-pare';
I can see the type
keyword is causing the issue and suspect it has to do with something named flow
which seems a static type checker.
What should I do to make it work?
- Same problem here. – André Bonna Commented Apr 29, 2020 at 17:04
2 Answers
Reset to default 11Just import like
import Select from "react-select";
Please note that: import Select from "react-select";
as above may not be enough!
In my case, in VSCODE there are macros that when invoked, generates someting like:
import { valueFocusAriaMessage } from 'react-select/src/accessibility'
Comment out / delete the line to solve the syntax error problem. I emphasize the issue since the line is added at the top, while you may not notice it! Beware.