CSS错误源映射信息在URL()声明中不可用(找到了孤立CR,请尝试removeCR选项)

在项目中执行NPM启动时遇到问题。 我收到此错误消息:

./src/assets/base.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/react-scripts/node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/assets/base.scss)
Error: resolve-url-loader: CSS error
  source-map information is not available at url() declaration (found orphan CR,try removeCR option)

CSS错误源映射信息在URL()声明中不可用(找到了孤立CR,请尝试removeCR选项)

jiangpingshe 回答:CSS错误源映射信息在URL()声明中不可用(找到了孤立CR,请尝试removeCR选项)

在IDE中打开文件* .css,然后选择行尾到LF(在我的情况下,我已将CRLF更改为LF)。

,

此问题可能有多种原因,我将给出3种可能的解决方案,请尝试所有解决方案

  1. 尝试更新index.js中存在的node_modules\resolve-url-loader,因此这里 在var options

var options = Object.assign({
      sourceMap: loader.sourceMap,engine: 'postcss',silent: false,absolute: false,keepQuery: false,**
      removeCR: false-- > make this "true" **,root: false,debug: false,join: joinFn.defaultJoin
    }

然后重新启动您的应用

  1. 下一个解决方案与上述相同,将行序列结尾更改为LF See screenshot below to know how it is done in VS Code

  2. 通过逐一注释CSS文件并运行代码以查找包含错误的文件来检查CSS文件。检查所有导入语句以及CSS文件中的Web链接。

P.S。这是我的第一个答案,所以请对我轻松一点:p 有关我写的内容的更多参考,您也可以访问此链接-> For more details you can also refer this link

,
  1. 转到 node_modules/resolve-url-loader/index.js
  2. 找到 removeCR 选项(就我而言,它位于第 53 行)
  3. 将其从“假”改为“真”
  4. 重新启动您的应用
,

尝试将node_modules / resolve-url-loader / index.js中的 | otherwise = Left "fail" 更改为def unique_in_order(iterable): output = [] letter = None for current in iterable: if current != letter: output.append(current) letter = current return output ,希望有帮助。

,

在您的IDE中将“ CRLF”切换为“ LF”(反之亦然)(在我的情况下为Visual Studio代码)

enter image description here

enter image description here

,

对于仍然有此问题的任何人,我找到了永久解决方案。

您可以使用 .gitattributes 来防止文件被转换为 CRLF。

.gitattributes 文件看起来像这样

*.vcproj    eol=crlf
*.sh        eol=lf

添加

*.scss eol=lf

此设置强制 Git 在签入时将行尾规范化为 LF,并防止在签出文件时转换为 CRLF。

只需提交 .gitattributes 文件,您的文件就会在每个以 LF 行结尾的系统上检出。

本文链接:https://www.f2er.com/2820338.html

大家都在问