当我尝试使用npm start
运行React应用程序时,它失败并出现类型错误:no-undef
和no-restricted-globals
,而它实际上编译并运行时没有任何问题我同事的机器!
我更改了我的npm
和node
版本以匹配其他计算机上的版本,但我得到了相同的结果。
任何想法在版本中的其他地方都可能出现问题吗?
以下是所有错误:
Failed to compile.
./src/components/app/App.js
Line 53: 'propsTypes' is not defined no-undef
Line 99: 'onChangeRoute' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/app/AppLoader.jsx
Line 26: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/Login.jsx
Line 51: 'propTypes' is not defined no-undef
Line 57: 'defaultProps' is not defined no-undef
Line 87: 'onChangeField' is not defined no-undef
Line 100: 'onSubmit' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/Dashboard.jsx
Line 38: 'metricsRef' is not defined no-undef
Line 56: 'onScrolled' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/Overview.jsx
Line 136: 'onScrolled' is not defined no-undef
Line 138: 'renderTiles' is not defined no-undef
Line 164: 'setView' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/EventDetail.jsx
Line 17: 'propTypes' is not defined no-undef
Line 49: 'showDetail' is not defined no-undef
Line 53: 'renderList' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/Glancemode.jsx
Line 20: 'metricsRef' is not defined no-undef
Line 35: 'onScrolled' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/app-bar/AppBar.jsx
Line 131: 'toggle' is not defined no-undef
Line 135: 'toggleFilters' is not defined no-undef
Line 140: Unexpected use of 'close' no-restricted-globals
Line 144: 'gotoAndClose' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentBrand.jsx
Line 15: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentMethod.jsx
Line 30: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentType.jsx
Line 24: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentStatus.jsx
Line 29: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentAmount.jsx
Line 63: 'propTypes' is not defined no-undef
Line 75: 'showAlternate' is not defined no-undef
Line 81: 'hideAlternate' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/PaymentDescription.jsx
Line 9: 'propTypes' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/SexyLoader.jsx
Line 70: 'propTypes' is not defined no-undef
Line 81: 'hide' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/app-bar/ViewMode.jsx
Line 17: 'propTypes' is not defined no-undef
Line 28: 'changeView' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/TransactionItem.jsx
Line 65: 'propTypes' is not defined no-undef
Line 86: 'defaultProps' is not defined no-undef
Line 99: 'getAlignment' is not defined no-undef
Line 111: 'formatItemField' is not defined no-undef
Line 134: 'showDetail' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/TransactionDetail.jsx
Line 130: 'propTypes' is not defined no-undef
Line 172: 'resolveTripAddress' is not defined no-undef
Line 182: 'resolveTrip' is not defined no-undef
Line 229: 'resolveCountry' is not defined no-undef
Line 254: 'resolveCustomerCountry' is not defined no-undef
Line 267: 'editStatus' is not defined no-undef
Line 281: 'getInvoiceMenu' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/metrics/Metric.jsx
Line 140: 'propTypes' is not defined no-undef
Line 157: 'defaultProps' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/page-header/DateRange.jsx
Line 119: 'onOpen' is not defined no-undef
Line 126: Unexpected use of 'close' no-restricted-globals
Line 133: 'formatDate' is not defined no-undef
Line 137: 'calendarFormat' is not defined no-undef
Line 141: 'addFilter' is not defined no-undef
Line 157: 'onChangeStart' is not defined no-undef
Line 163: 'onChangeEnd' is not defined no-undef
Line 169: 'setRange' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/metrics/BasicMetrics.jsx
Line 75: 'propTypes' is not defined no-undef
Line 102: 'defaultProps' is not defined no-undef
Line 128: 'el' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/TransactionList.jsx
Line 37: 'propTypes' is not defined no-undef
Line 48: 'listRef' is not defined no-undef
Line 49: 'scroller' is not defined no-undef
Line 72: 'sortByField' is not defined no-undef
Line 98: 'onResized' is not defined no-undef
Line 109: 'onScrolled' is not defined no-undef
Line 118: 'calculateTiling' is not defined no-undef
Line 177: 'getAlignment' is not defined no-undef
Line 189: 'showDetail' is not defined no-undef
Line 197: 'hideDetail' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/filters/SavedFiltersList.jsx
Line 38: 'propTypes' is not defined no-undef
Line 49: 'remove' is not defined no-undef
Line 53: 'activate' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/filters/Search.jsx
Line 43: 'propTypes' is not defined no-undef
Line 55: 'performSearch' is not defined no-undef
Line 62: 'onChange' is not defined no-undef
Line 68: 'clearText' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/filters/FilterSideMenu.jsx
Line 97: 'propTypes' is not defined no-undef
Line 182: 'onChange' is not defined no-undef
Line 214: 'performSearch' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/filters/SavedFilters.jsx
Line 44: 'propTypes' is not defined no-undef
Line 57: 'closeDialog' is not defined no-undef
Line 63: 'showDialog' is not defined no-undef
Line 69: 'save' is not defined no-undef
Line 88: 'onChangeViewName' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/currency-switcher/CurrencySwitcher.jsx
Line 13: 'propTypes' is not defined no-undef
Line 19: 'defaultProps' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/popover/Popover.jsx
Line 14: 'propTypes' is not defined no-undef
Line 27: 'onOpen' is not defined no-undef
Line 33: Unexpected use of 'close' no-restricted-globals
Search for the keywords to learn more about each error.
./src/components/transactions/TransactionsHeader.jsx
Line 53: 'propTypes' is not defined no-undef
Line 68: 'getAlignment' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/button/Button.jsx
Line 7: 'propTypes' is not defined no-undef
Line 15: 'defaultProps' is not defined no-undef
Search for the keywords to learn more about each error.
./src/components/transactions/BulkActions.jsx
Line 44: 'propTypes' is not defined no-undef
Line 56: 'onAction' is not defined no-undef
Search for the keywords to learn more about each error.
答案 0 :(得分:1)
is not defined no-undef
表示未声明或导入。例如
PropTypes需要导入,如import PropTypes from 'prop-types';
。如果您这样做,请确保您已经运行npm install
。
或者确保重新安装依赖项。删除node_modules
文件夹,
然后在该npm cache clean
之后运行npm install
。
答案 1 :(得分:0)
感谢大家,感谢您尝试解决我的问题。问题原来是在掉毛! create-react-scripts
似乎有自己的缘故。当我安装eslint
时,错误开始仅显示为警告,因此我现在看到not defined
警告,而不是not used
错误。至少应用程序工作,我可以处理删除未使用的变量。
再次感谢!