npm run build - 编译失败 - 无法读取未定义的属性“toLowerCase" [英] npm run build - Failed to compile - Cannot read property 'toLowerCase' of undefined

查看:171
本文介绍了npm run build - 编译失败 - 无法读取未定义的属性“toLowerCase"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的反应应用程序 (create-react-app) 中使用 npm run build 时,它无法编译并给我消息 Cannot read property 'toLowerCase' of undefined.

When using npm run build in my react app (create-react-app), it fails to compile and gives me the message Cannot read property 'toLowerCase' of undefined.

我没有在我的应用程序中使用 toLowerCase 并且认为使用它的唯一地方是在脚本中:node_modules/react-scripts/scripts/build.js在这段代码中:

I am not using toLowerCase in my app and figured the only place where this is used is in the script : node_modules/react-scripts/scripts/build.js in this piece of code:

if (
  process.env.CI &&
  (typeof process.env.CI !== 'string' ||
    process.env.CI.toLowerCase() !== 'false') &&
  messages.warnings.length
) {
  console.log(
    chalk.yellow(
      '\nTreating warnings as errors because process.env.CI = true.\n' +
      'Most CI servers set it automatically.\n'
    )
  );
  return reject(new Error(messages.warnings.join('\n\n')));
}

对我来说似乎很奇怪的是,即使在那里,它也不应该给我 Cannot read property 'toLowerCase' of undefined 因为如果 processe.env.CI 是未定义的它应该将第一个条件语句读取为 false-y,甚至不读取 processe.env.CI.toLowerCase.我也试过删除这整段代码,但我得到了同样的错误.我有另一个 react-app 并且 npm run build 命令工作得很好,所以我真的很困惑,我什至不知道应该在哪里寻找答案.

What seems strange to me is that even there, it should not even give me Cannot read property 'toLowerCase' of undefined because if processe.env.CI was undefined it should read the first conditional statement as false-y and not even read processe.env.CI.toLowerCase. Also I have tried deleting this whole section of code and I get the same error. I have another react-app and the npm run build command works just fine, so I am really at loss wondering where I should even look for the answer.

推荐答案

好的,这很奇怪,但这是我的问题:

Ok, this is very weird but here is what my problem was:

.collage{
margin: ;
display: flex;
flex-wrap:wrap;
justify-content: space-between;
align-items: stretch;}

我的边距值打错了,这个简单的错误阻碍了我的工作并给我一个 toLowerCase 问题!!!!

I had a typo for my margin value, and this simple bug was what was blocking the wole thing and giving me a toLowerCase issue!!!!

万万没想到!

这篇关于npm run build - 编译失败 - 无法读取未定义的属性“toLowerCase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆