繁体   English   中英

不需要React.js组件

[英]Cannot require a React.js component

我正在尝试导入一个名为'fixed-data-table'的React.js组件,并且在运行时遇到了问题:

var FixedDataTable = require('fixed-data-table');

它引发以下错误:

pez@pezbox:~/projects/react-server-example$ node server.js 
/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableValue.js:65
      Object.assign(destination, propertyObjects[i]);
             ^
TypeError: undefined is not a function
    at Function.ImmutableValue.mergeAllPropertiesInto (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableValue.js:65:14)
    at new ImmutableObject (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableObject.js:50:20)
    at Object.<anonymous> (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/FixedDataTableCell.react.js:22:21)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/FixedDataTableCellGroup.react.js:19:26)

我安装了使用

sudo npm install

奇怪的是,如果由于访问权限而排除sudo ,它将不起作用。

有什么问题的指针吗?

您需要导入object-assign

这是你的错误

Object.assign(destination, propertyObjects[i]);
       ^
TypeError: undefined is not a function

您可以像这样导入object-assign

/** @jsx React.DOM */
var assign = require('object-assign');

首先,您可能想使用npm install 这是我使用的package.json 注意object-assign

{
  "name": "gae-react-flux-todos",
  "version": "0.0.1",
  "description": "A simple TODOS app in React and Flux, built on top of Google App Engine",
  "author": "Ben Grunfeld",
  "repository": "https://github.com/bengrunfeld/gae-react-flux-todos",
  "readme": "https://github.com/bengrunfeld/gae-react-flux-todos/blob/master/README.md",
  "license": "Apache 2",
  "devDependencies": {
    "gulp": "^3.8.11",
    "gulp-browserify": "^0.5.0",
    "gulp-clean": "^0.3.1",
    "gulp-concat": "^2.2.0",
    "gulp-react": "^2.0.0",
    "gulp-replace": "^0.5.3",
    "browserify": "^9.0.3",
    "react": "^0.12.2",
    "reactify": "^0.13.1",
    "es6-promise": "^1.0.0",
    "flux": "^2.0.1",
    "object-assign": "^1.0.0",
    "jest-cli": "^0.4.0",
    "react-tools": "^0.12.0",
    "classnames": "1.2.0"
  }
}

暂无
暂无

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

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