我正在按照本文档设置Saleor店面。然而,在Windows CMD上调用命令npm start
后,弹出了大量错误消息。
我是npm
的新手,不确定是否遗漏了配置中的任何内容。
如果你需要更多信息,请告诉我。如有任何提示,我们将不胜感激。
最后几条错误消息的屏幕截图:
- 屏幕输出的开始部分:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:myworksaleor-devsaleor-storefront> npm start
> saleor-site@3.0.0-a.0 start
> next dev -p 3000
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from C:myworksaleor-devsaleor-storefront.env.development
info - Loaded env from C:myworksaleor-devsaleor-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:myworksaleor-devsaleor-storefrontbabel.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:myworksaleor-devsaleor-storefrontnode_moduleseslint-config-airbnb-typescriptpackage.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>
这是因为您可能在Windows下编辑了该文件,该文件使用CR+LF作为行尾。您已经配置了"更漂亮"(或者默认情况下使用模板(set"漂亮"来检查行尾是否为LF(unix风格的行尾(,并将不正确的格式报告为错误。
有关换行符的详细信息:https://en.wikipedia.org/wiki/Newline
解决方案
您可以设置更漂亮以允许CR+LF行结尾,也可以将每个源文件转换为使用LF行结尾。
允许CR+LF行结束
您应该尝试在eslintrc
:中查找此部分
'prettier/prettier': [
'error',
{
'endOfLine': '[something something]',
}
]
并将"endOfLine"行更改为:
'endOfLine': 'auto',
或
'endOfLine': 'crlf',
其中任何一个都应允许使用CR+LF。
将CR+LF转换为LF(推荐(
你可以在编辑器中手动完成,也可以让更漂亮的人来完成。在您的项目文件夹中,创建.prettierrc.json
(如果您正在使用模板,它可能已经存在,如果存在,请编辑现有的模板inst(。
在.prettierrc.json
:中设置此选项
{
"endOfLine": "lf"
}
然后对npm运行npx prettier --write src/
或对纱线运行yarn prettier --write src/
。
之后,您可以运行npx prettier --check src/
来检查源文件的格式是否正确。
您可能需要查看程序:
dos2unix中文件外文件,反之亦然(unix2dos(,用于剥离换行。