You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the API. I installed documention.js (13.2.5) using npm (6.14.16) and it is working fine from the command line. However this does not generate a module in node_modules and when I run a program with
var documentation = require('documentation');
I get
Error: Cannot find module 'documentation'
How do I install the module. I can't find instructions in the documentation..
The default instructions - npm install -g documentation - are to install documentation globally, as a command-line tool. If you'd like to install it locally, so you can use it with require, you can drop the -g argument and run npm install documentation
Thanks. I eventually found the module in /lib and tried requiring it from there, but came up with an error so abandoned that approach. I just re-installed documentation as suggested and I am getting the same error.
The code
let documentation=require ('documentation');
let sendView = require('./suds/send-view');
module.exports = async function (req, res) {
documentation.build([req.query.file])
.then(documentation.formats.html)
.then(output => {
let result = sendView(res, 'report', output);
});
return('OK');
}
req.query.field has the path/file name (./suds/db.js) and sendView sends the results to the screen.
TypeError: Cannot read property 'parseExtension' of undefined
at mergeConfig (/home/bob/ex/suds/base/node_modules/documentation/src/merge_config.js:84:35)
at configure (/home/bob/ex/suds/base/node_modules/documentation/src/index.js:48:24)
at Object.build (/home/bob/ex/suds/base/node_modules/documentation/src/index.js:225:34)
at module.exports (/home/bob/ex/suds/base/bin/docs.js:29:17)
The default instructions - npm install -g documentation - are to install documentation globally, as a command-line tool. If you'd like to install it locally, so you can use it with require, you can drop the -g argument and run npm install documentation
# node ./require.js
/Users/brentthompson/Projects/temp/doctest2/require.js:1
const doc = require('documentation')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/brentthompson/Projects/temp/doctest2/node_modules/documentation/src/index.js from /Users/brentthompson/Projects/temp/doctest2/require.js not supported.
Instead change the require of index.js in /Users/brentthompson/Projects/temp/doctest2/require.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/brentthompson/Projects/temp/doctest2/require.js:1:13) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v18.18.2
Activity
bobbrowning commentedon Feb 18, 2022
I have a workaround at lease...
exec(
documentation build ./bin/suds/admin.js --shallow -f md | markdown,....
Lacks elegance but works for my purposes.
tmcw commentedon Feb 18, 2022
The default instructions -
npm install -g documentation- are to install documentation globally, as a command-line tool. If you'd like to install it locally, so you can use it withrequire, you can drop the-gargument and runnpm install documentationbobbrowning commentedon Feb 19, 2022
Thanks. I eventually found the module in /lib and tried requiring it from there, but came up with an error so abandoned that approach. I just re-installed documentation as suggested and I am getting the same error.
The code
let documentation=require ('documentation');
let sendView = require('./suds/send-view');
module.exports = async function (req, res) {
documentation.build([req.query.file])
.then(documentation.formats.html)
.then(output => {
let result = sendView(res, 'report', output);
});
return('OK');
}
req.query.field has the path/file name (./suds/db.js) and sendView sends the results to the screen.
TypeError: Cannot read property 'parseExtension' of undefined
at mergeConfig (/home/bob/ex/suds/base/node_modules/documentation/src/merge_config.js:84:35)
at configure (/home/bob/ex/suds/base/node_modules/documentation/src/index.js:48:24)
at Object.build (/home/bob/ex/suds/base/node_modules/documentation/src/index.js:225:34)
at module.exports (/home/bob/ex/suds/base/bin/docs.js:29:17)
brenthompson commentedon Feb 27, 2024
This doesn't work on version 14.0.3 or later.
$ cat require.js
tmcw commentedon Feb 27, 2024
Yes, looks like the changelog mentions updating to node v14 but not the move to native esm.
You'll need to use
importfor 14.x