Error: package must be an instance of Package
Opened this issue · 7 comments
when running 'dgeni ./dgeni-run.js' to generate docs, I have this error: '
node_modules/dgeni/lib/Dgeni.js:45
throw new Error('package must be an instance of Package');
^
Error: package must be an instance of Package
at Dgeni.package (/home/chaaben/git/projects/UNIWAPP/repos/app-pds/node_modules/dgeni/lib/Dgeni.js:45:19)
at /home/chaaben/git/projects/UNIWAPP/repos/app-pds/node_modules/dgeni/lib/Dgeni.js:26:57
at Array.map (<anonymous>)
at new Dgeni (/home/chaaben/git/projects/UNIWAPP/repos/app-pds/node_modules/dgeni/lib/Dgeni.js:26:18)
at Object.<anonymous> (/home/chaaben/git/projects/UNIWAPP/repos/app-pds/node_modules/dgeni/lib/gen-docs.js:26:13)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
I 'm testing with a basic configuration, this is my dgeni-run.js file:
var Dgeni = require('dgeni');
var Package = require('dgeni').Package;
var myPackage = new Package('myDoc', [
// require('dgeni-packages/ngdoc'),
// require('dgeni-packages/nunjucks'),
]);
console.log(myPackage)
var dgeni = new Dgeni([myPackage]);
dgeni.generate();
It might be because you have "required" dgeni
twice. Instead try:
var Dgeni = require('dgeni');
var Package = Dgeni.Package;
I have the same error after this modification
dgeni: 0.4.9
dgeni-packages: 0.22.0
I'll try to reproduce on my side...
OK, so I realise what the problem is:
If you want to use dgeni
via the command line then the file that you pass it must export a package. What you have is a file that is actually running dgeni by itself and not exporting anything.
You have two choices:
a) Change your file to simply export your package:
my-doc.js
var Package = require('dgeni').Package;
module.exports = new Package('myDoc', [
// require('dgeni-packages/ngdoc'),
// require('dgeni-packages/nunjucks'),
]);
in which case you can then run this via the command line dgeni ./my-doc.js
b) Do not use the command line at all and simply run the file you have directly:
node dgeni-run.js
thank you, my problem is resolved with your solution.