question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'lws/lib/usage'

See original GitHub issue

I am using lws for mocking some API endpoints and everything worked fine until I’ve removed node_modules and ran npm install again. Now starting the server (ws -c mock-server/lws.config.js) throws this error:

Error: Cannot find module 'lws/lib/usage'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at MockResponse.middleware (...\node_modules\lws-mock-response\index.js:42:21)
...

The configuration file (mock-server/lws.config.js) is very small :

module.exports = {
    port: 8789,
    mocks: require('./mocks')
};

where mocks.js exports a lambda following the pattern from the documentation:

module.exports = MockBase => class MockService extends MockBase {
    mocks(options) {
        return [...]; // several route configurations
    }
};

I’ve looked in node_modules/lws/lib and indeed there is no usage.js file.

Am I missing something here or is it a regression from the lws-mock-response module?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stefan-orzucommented, Jul 12, 2018

@tylermassey If a project is for some reason locked to version 2.5.2, a workaround would be to manually add a dependency to “lws” version 1.2.6 in order to prevent that issue from happening.

1reaction
stefan-orzucommented, Jul 10, 2018

I’ve reinstalled and everything works fine now. Thank you very much for the quick response and fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >
Solved: Cannot find module react : npm install - YouTube
Solved: Cannot find module react : npm install. 59K views 3 years ago React · CodeDocu Developer C# Asp Net Angular.
Read more >
Error: Cannot find module 'express' - YouTube
Error: Cannot find module 'express'Error: Cannot find module 'cors'Error: Cannot find module 'body-parser'Error: Cannot find module ...
Read more >
require.resolve "Error: Cannot find module" but ... - Reddit
this is all I'm trying to do require.resolve("stream-browserify") but I get a module not found error even though I can see it exists...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found