Skip to content

Error: Cannot find module 'documentation' #1482

Open

Description

@bobbrowning

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..

Activity

  1. bobbrowning commented on Feb 18, 2022

    @bobbrowning
    Author

    I have a workaround at lease...
    exec(
    documentation build ./bin/suds/admin.js --shallow -f md | markdown,
    ....

    Lacks elegance but works for my purposes.

  2. tmcw commented on Feb 18, 2022

    @tmcw
    Member

    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

  3. bobbrowning commented on Feb 19, 2022

    @bobbrowning
    Author

    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)

  4. brenthompson commented on Feb 27, 2024

    @brenthompson

    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

    This doesn't work on version 14.0.3 or later.

    $ cat require.js

    const doc = require('documentation')
    console.log(doc)
    
    # 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
    
    
  5. tmcw commented on Feb 27, 2024

    @tmcw
    Member

    Yes, looks like the changelog mentions updating to node v14 but not the move to native esm.

    You'll need to use import for 14.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions