Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError, Windows Support #187

Closed
Venipa opened this issue Sep 11, 2022 · 9 comments
Closed

ModuleNotFoundError, Windows Support #187

Venipa opened this issue Sep 11, 2022 · 9 comments

Comments

@Venipa
Copy link

Venipa commented Sep 11, 2022

 "dependencies": {
    "mailing": "^0.7.7",
    "mailing-core": "^0.7.7",
    "next": "^12.3.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }

Node: v16.16.0, 14.20.0, 18.9.0
Shell: PowerShell v5.1.19041.1682

While running the development server i get this error
image

also while running npx mailing i get this error upon start:
image

@alexfarrill
Copy link
Collaborator

Hi @Venipa , sorry to hear that you are experiencing a problem. Could I ask you to check what the size of your .mailing/src/moduleManifest.js is after you start the server, it should be around 15k, but I have sometimes seen a similar error when esbuild includes other packages that are installed on the system that it should ignore, curious to see if that is the same problem you are having. If that is the case, then likely something is not working with this part of the code in buildManifest if that helps you debug:

external: getNodeModulesDirsFrom("."),

Thanks for using mailing! And if you have a moment to tell us a bit more about how you're using mailing, we'd love to hear more about it in this thread: #121

@Venipa
Copy link
Author

Venipa commented Sep 15, 2022

Hi @Venipa , sorry to hear that you are experiencing a problem. Could I ask you to check what the size of your .mailing/src/moduleManifest.js is after you start the server, it should be around 15k, but I have sometimes seen a similar error when esbuild includes other packages that are installed on the system that it should ignore, curious to see if that is the same problem you are having. If that is the case, then likely something is not working with this part of the code in buildManifest if that helps you debug:

external: getNodeModulesDirsFrom("."),

Thanks for using mailing! And if you have a moment to tell us a bit more about how you're using mailing, we'd love to hear more about it in this thread: #121

@alexfarrill

5.45 MB (5,722,437 bytes)
image

isnt it better to use process.cwd() instead of "." ?

also i've tried running mailing in codespaces (linux) and it works there

@alexfarrill
Copy link
Collaborator

@Venipa thanks, I'm not sure if process.cwd() would behave differently from . but it is worth a shot. I made a beta version "0.7.9-next.0" that does just that which you can use like this:
yarn add mailing@0.7.9-next.0 mailing-core@0.7.9-next.0

would you let us know if it solves your problem?

if not, can you let me know if you have packages installed globally? we don't currently look for node_modules outside of the project and its parent directories, but that could be an issue if you are importing packages that live in a global node_module directory that is outside of the set of all parent directories from your project root. Thanks!

@bruceharrison1984
Copy link

bruceharrison1984 commented Sep 21, 2022

I'm getting the same error on 0.8.0.

$ npx mailing
mailing starting preview server
event - compiled client and server successfully in 3.4s (175 modules)
mailing watching for changes to src\emails
mailing running preview at http://localhost:3883/
wait  - compiling / (client and server)...
error - ./src/moduleManifest.js
Module not found: Can't resolve './lib/beautify' in 'C:\Users\leeha\Development\poetz-lake-house\.mailing\src'
wait  - compiling /_error (client and server)...
error - ./src/moduleManifest.js
Module not found: Can't resolve './lib/beautify' in 'C:\Users\leeha\Development\poetz-lake-house\.mailing\src'
mailing 500 / 6482ms
mailing 500 /favicon.ico 21ms

mailing.config.json

{
  "typescript": true,
  "emailsDir": "./src/emails",
  "outDir": "./previews_html",
  "anonymousId": "58d2f4cc-0d24-45bb-b522-3a091f9b4c2d"
}

@nycgio
Copy link

nycgio commented Oct 24, 2022

I am also getting this error on windows machine did anyone find out a solution?

@alexfarrill
Copy link
Collaborator

Unfortunately, I have not found a solution to this, but I can give you some notes on what I had tried debugging:

  • I was speculating it may have to do with mixing / and \ in those paths on Windows in the modulManifest.js file, which is generated by setup.ts. However, in setup.ts we're using import { resolve, posix, relative } from "path"; which should choose the proper file delimeter for each platform. I don't think it is related to this after all.
  • looking at the specific error you posted, that seems to be referenced in js-beautify, which is a dependency of mjml-cli:
 grep -R "./lib/beautify"  node_modules
node_modules/js-beautify/js/index.js:    "./lib/beautify",
node_modules/js-beautify/js/index.js:    "./lib/beautify-css",
node_modules/js-beautify/js/index.js:    "./lib/beautify-html"

It may have to do with the way that the .mailing folder includes its node_modules -- there is no directory .mailing/node_modules, instead we rely on module resolution traversing up to the root directory node_modules and finding those libraries correctly. I might give a look in your project root node_modules directory to see if you have a js-beautify directory and it has all the right stuff in it:

ls node_modules/js-beautify/js/lib/*
node_modules/js-beautify/js/lib/beautifier.js		node_modules/js-beautify/js/lib/beautify-html.js
node_modules/js-beautify/js/lib/beautifier.min.js	node_modules/js-beautify/js/lib/beautify.js
node_modules/js-beautify/js/lib/beautify-css.js		node_modules/js-beautify/js/lib/cli.js

node_modules/js-beautify/js/lib/unpackers:
javascriptobfuscator_unpacker.js	p_a_c_k_e_r_unpacker.js
myobfuscate_unpacker.js			urlencode_unpacker.js

Sorry I don't know a concrete next step here, but hopefully that helps your debugging?

@dextel2
Copy link

dextel2 commented Dec 12, 2022

+1 facing the same issue here

@alexfarrill
Copy link
Collaborator

Mailing does not currently run on Windows, however we would love a PR that fixes that. I am closing this issue for now, but #172 is our ticket to support Windows. Pull requests welcome!

@Venipa
Copy link
Author

Venipa commented Dec 12, 2022

current semi fix is to use wsl for development

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants