简体   繁体   English

node.js:windows 上出现“TypeError:_ref 未定义”错误,但在 linux 上运行正常

[英]node.js: “TypeError: _ref is undefined” error on windows but runs ok on linux

I'm trying to install and run a node app on windows that is running ok on linux.我正在尝试在 windows 上安装并运行一个节点应用程序,该应用程序在 linux 上运行正常。 It seems to install ok but when I call npm start I get the following error:似乎安装正常,但是当我调用npm start时,出现以下错误:

TypeError: _ref is undefined
RangeInput/_this.handleSlider
e:/temp/pp/reactsearch/node_modules/@appbaseio/reactivesearch/lib/components/range/RangeInput.js:143

  140 | };
  141 | 
  142 | _this.handleSlider = function (_ref) {
> 143 |   var start = _ref.start,
      | ^  144 |       end = _ref.end;
  145 | 
  146 |   _this.setState({

I'm new to node.我是节点新手。 Can anyone suggest where to start to figure out what I've done wrong?谁能建议从哪里开始找出我做错了什么? I followed the same install process I used to install and run the app on linux.我遵循与在 linux 上安装和运行应用程序相同的安装过程。

Thanks, Phil谢谢,菲尔

So sometimes this error pops up in React/Node apps you build when you're calling or referencing something too early.因此,当您过早调用或引用某些内容时,有时会在您构建的 React/Node 应用程序中弹出此错误。

I don't know your whole code but what it looks like is React isn't reading on time the argument you passed into your function so when you call the .start property, it can't read what that property is because it's not referencing anything.我不知道您的整个代码,但看起来 React 没有按时读取您传递给 function 的参数,所以当您调用.start属性时,它无法读取该属性是什么,因为它没有引用任何事物。

Try instantiating a value for the variable when the component mounts or using promises to make sure that your function argument is defined before the code after it runs.尝试在组件挂载时为变量实例化一个值,或使用承诺确保在代码运行后在代码之前定义您的 function 参数。 Or if those methods don't fit your code, the bottom line is to make sure that your argument is being passed into the function first.或者,如果这些方法不适合您的代码,最重要的是确保您的参数首先被传递到 function 中。 Otherwise, it'll error out.否则会报错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM