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 './server'

See original GitHub issue

Describe the bug I have created a separate module that is an express server which is being started in the main i.e index.js file. The issue is that the imported module works fine when I do npm run electron:start and the server listens but when I build it throws an exeption saying Cannot find module './server'.

To Reproduce Steps to reproduce the behavior:

  1. Initialize a new capacitor project.
  2. Add electron using these steps
  3. Add a module in the ./src and import it in index.jsfile.
  4. Create build and run the app.

Expected behavior Compiled code from ./build folder should all go to production build.

Screenshots production: image electron:start image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version 85.0.4183.102 (Official Build) (64-bit)

Additional context By the way the app and server works find if I do everything in one file.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
IT-MikeScommented, Oct 22, 2020

Fixed with, 39a8e4b62d71d189b77d8d09ec4ee2626fd15939

This will be in 1.3.1

0reactions
LuizTokuharacommented, Dec 12, 2020

Fixed with, 39a8e4b This will be in 1.3.1

@LuizTokuhara please see the above, please make sure you are using the latest version of the electron platform

Hi IT-MikeS, thanks for your reply. Actually on my project, electron is not finding the express module, but it is included in node_modules (root and electron). Don’t know why it is happening. Screen Shot 2020-12-12 at 13 04 33

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
This happens when a first npm install has crashed for some reason (SIGINT of npm), or that the delay was too long, or...
Read more >
Error: cannot find module [Node npm Error Solved]
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
Read more >
Cannot find module 'X' error in Node.js
To solve the "Cannot find module" error in Node.js, make sure to install the package from the error message if it's a third-party...
Read more >
How to resolve "Cannot find module" error in Node
The issue is that Node is unable to find the module that you are trying to import into your Node application. The most...
Read more >
How to fix npm cannot find module error
The cannot find module error occurs because npm cannot find the module required by the index.js file. In this case, the axios module....
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