简体   繁体   English

琐碎的要求引发错误

[英]Trivial require throws error

I'm trying to work with a popular dependency injection library, electrolyte , but even a trivial script requiring it throws an error. 我正在尝试使用流行的依赖项注入库, 电解质 ,但是即使是琐碎的脚本要求它也会引发错误。 I can't find any discussion or issues related to my error, but since I'm new to node, I'd like to check that I'm not doing something obviously wrong before appealing to the author. 我找不到与错误有关的任何讨论或问题 ,但是由于我是Node的新手,因此在向作者提出上诉之前,我想检查一下自己是否在做明显的错误。

Install electrolyte: 安装电解液:

npm install electrolyte

Run this 1-line app, test.js , with node: 运行带有节点的1行应用程序test.js

var di = require("electrolyte");

Get this error: 得到这个错误:

util.js:555
  ctor.prototype = Object.create(superCtor.prototype, {
                      ^
TypeError: Object prototype may only be an Object or null
    at Function.create (native)
    at Object.exports.inherits (util.js:555:27)
    at Object.<anonymous> (/home/vagrant/tmp/node_modules/electrolyte/lib/container.js:42:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/vagrant/tmp/node_modules/electrolyte/lib/index.js:1:79)

I've tried this in two environments (node on ubuntu from packages, mac from brew) with identical results. 我已经在两个环境(软件包中的ubuntu上的节点,brew的mac上)中尝试过此方法,并且结果相同。 I can install and require other libraries without issue. 我可以安装并需要其他库而不会出现问题。 Versions of node and electrolyte appear to be up to date. 节点和电解质的版本似乎是最新的。

Looks like the versions of node I had through brew and through debian packages were pretty old. 看来我通过brew和通过debian软件包所拥有的节点版本已经很老了。 Following the installation guide to add node's own debian repository corrected the problem. 按照安装指南添加节点自己的debian存储库可以更正此问题。

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

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