我正在按照本檔案設定 Saleor 店面。但是,npm start在Windows CMD上呼叫該命令后,彈出了大量的錯誤訊息。
我是新手npm,不確定我是否錯過了配置中的任何內容。
如果您需要更多資訊,請告訴我。任何提示將不勝感激。
最后幾條錯誤訊息的螢屏截圖:
- 螢屏輸出的開始部分:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\my\work\saleor-dev\saleor-storefront> npm start
> [email protected] start
> next dev -p 3000
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from C:\my\work\saleor-dev\saleor-storefront\.env.development
info - Loaded env from C:\my\work\saleor-dev\saleor-storefront\.env
warn - React 17.0.1 or newer will be required to leverage all of the upcoming features in Next.js 11. Read more: https://nextjs.org/docs/messages/react-version
info - Using webpack 4. Reason: future.webpack5 option disabled https://nextjs.org/docs/messages/webpack5
Defining routes from exportPathMap
Warning: Reverting webpack devtool to 'inline-source-map'.
Changing the webpack devtool in development mode will cause severe performance regressions.
Read more: https://nextjs.org/docs/messages/improper-devtool
Warning: Built-in CSS support is being disabled due to custom CSS configuration being detected.
See here for more info: https://nextjs.org/docs/messages/built-in-css-disabled
info - Using external babel configuration from C:\my\work\saleor-dev\saleor-storefront\babel.config.js
error - ./src/globalStyles/scss/index.scss (./node_modules/css-loader??ref--5-1!./node_modules/sass-loader/lib/loader.js!./src/globalStyles/scss/index.scss)
Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1
Issues checking in progress...
(node:14980) [DEP0128] DeprecationWarning: Invalid 'main' field in 'C:\my\work\saleor-dev\saleor-storefront\node_modules\eslint-config-airbnb-typescript\package.json' of 'dist/eslint-config-airbnb-typescript.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
...
然后,
- 錯誤訊息:
... a massive number of error messages omitted ...
ERROR in src/views/Search/SearchPage.tsx:114:14
prettier/prettier: Delete `?`
112 | if (data && data.products === null) {
113 | return <NotFound />;
> 114 | }
| ^
115 |
116 | if (!isOnline) {
117 | return <OfflinePlaceholder />;
ERROR in src/views/Search/SearchPage.tsx:115:1
prettier/prettier: Delete `?`
113 | return <NotFound />;
114 | }
> 115 |
| ^
116 | if (!isOnline) {
117 | return <OfflinePlaceholder />;
118 | }
ERROR in src/views/Search/SearchPage.tsx:116:29
prettier/prettier: Delete `?`
114 | }
115 |
> 116 | if (!isOnline) {
| ^
117 | return <OfflinePlaceholder />;
118 | }
119 | }}
ERROR in src/views/Search/SearchPage.tsx:117:45
prettier/prettier: Delete `?`
115 |
116 | if (!isOnline) {
> 117 | return <OfflinePlaceholder />;
| ^
118 | }
119 | }}
120 | </TypedSearchProductsQuery>
uj5u.com熱心網友回復:
這是因為您可能在 Windows 下編輯了檔案,它使用 CR LF 作為行尾。并且您已經配置了 prettier(或默認使用模板)設定 prettier 以檢查行尾是否為 LF(unix 樣式的行尾),并將格式不正確報告為錯誤。
有關換行的更多資訊:https ://en.wikipedia.org/wiki/Newline
解決方案
您可以設定 prettier 以允許 CR LF 行結尾,或者將每個源檔案轉換為使用 LF 行結尾。
允許 CR LF 行結束
您應該嘗試在以下位置找到此部分eslintrc:
'prettier/prettier': [
'error',
{
'endOfLine': '[something something]',
}
]
并將“endOfLine”行更改為:
'endOfLine': 'auto',
要么
'endOfLine': 'crlf',
其中任何一個都應該允許使用 CR LF。
將 CR LF 轉換為 LF(推薦)
您可以在編輯器中手動完成,也可以讓 prettier 完成。在您的專案檔案夾中,創建.prettierrc.json(如果您正在使用模板,它可能已經存在,如果存在,請編輯現有的一個 inst)。
將此選項設定為.prettierrc.json:
{
"endOfLine": "lf"
}
然后運行npx prettier --write src/??npm 或yarn prettier --write src/yarn。
之后,您可以運行npx prettier --check src/以檢查源檔案的格式是否正確。
uj5u.com熱心網友回復:
你可能想看看這個程式:
dos2unix infile outfile 和反之亦然 (unix2dos) 用于剝離換行符。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/436845.html
上一篇:NPM啟動問題(反應)
