我正在尝试导入名为' 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
,则无法正常工作。
任何有关出错的指示?
答案 0 :(得分:1)
您需要导入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"
}
}