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

"premail init" failing #53

Closed
CBoensel opened this issue Jan 14, 2022 · 16 comments
Closed

"premail init" failing #53

CBoensel opened this issue Jan 14, 2022 · 16 comments
Labels
Status: Abandoned No activity, considered abandoned. Status: Done Completed. Type: Question Requests for help on how to use the project, or general questions. x-Bot: No Changelog This will not be included in automated changelog generation.

Comments

@CBoensel
Copy link

Support Question

System

Windows 10 x64, Node 12.x

Premail version

current / most recent

Your question

any idea why this is?

internal/modules/cjs/loader.js:797
    throw err;
    ^
Error: Cannot find module 'C:\Users\cbnsel\AppData\Roaming\npm\node_modules\premail\gulpfile.js'
Require stack:
- C:\Users\cbnsel\AppData\Roaming\npm\node_modules\premail\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\cbnsel\AppData\Roaming\npm\node_modules\premail\index.js:10:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\cbnsel\\AppData\\Roaming\\npm\\node_modules\\premail\\index.js'
  ]
}

hint, installation of premail ended with warnings.

@CBoensel CBoensel added the Type: Question Requests for help on how to use the project, or general questions. label Jan 14, 2022
@rootwork
Copy link
Member

@CBoensel Thanks for the report! I've just pushed a new release that I believe will fix this:

https://github.com/premail/premail/releases/tag/v2.0.3
https://www.npmjs.com/package/premail

Please let me know.

@CBoensel
Copy link
Author

@rootwork Thanks, just checked. But on another device now, still same specs though, node 12 through nvm this time.

Seeing...

premail init
internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module './gulpfile'
Require stack:
- C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\index.js:9:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\carsten\\AppData\\Roaming\\nvm\\v12.13.0\\node_modules\\premail\\index.js'
  ]
}

...still. I'm going to drop my logs from the install this time:

npm install -g premail
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
C:\Program Files\nodejs\premail -> C:\Program Files\nodejs\node_modules\premail\index.js

> fibers@5.0.0 install C:\Program Files\nodejs\node_modules\premail\node_modules\fibers
> node build.js || nodejs build.js

`win32-x64-72` exists; testing
Binary is fine; exiting
npm WARN notsup Unsupported engine for premail@2.0.3: wanted: {"node":"^12 || ^14 || ^16","npm":"^7 || ^8"} (current: {"node":"12.13.0","npm":"6.12.0"})
npm WARN notsup Not compatible with your version of node/npm: premail@2.0.3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\premail\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\premail\node_modules\mjml-cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\premail\node_modules\sass\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules\premail\node_modules\mocha\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN node-sass-json-importer@4.3.0 requires a peer of node-sass@>=3.5.3 but none is installed. You must install peer dependencies yourself.

+ premail@2.0.3
added 1260 packages from 544 contributors and updated 6 packages in 77.355s

Personally I think it might worth considering the "SKIPPING OPTIONAL DEPENDENCY" logs.

Thanks for having a look.
Cheers,
Carsten

@rootwork
Copy link
Member

OK, I think I've got it now. Try https://github.com/premail/premail/releases/tag/v2.0.4 or the version now on npm. Turns out the error about not finding a file was actually a red herring; it was a mismatch in the node/npm requirements that had been set. I added a GitHub Action to test for this to make sure it doesn't happen again. I also fixed one internal path that may have failed on Windows.

In terms of the "optional dependency" errors, this is a known npm thing. I agree it's annoying and confusingly prominent.

Let me know how far you get with this version.

@CBoensel
Copy link
Author

Thanks, @rootwork! Just installed the patch. Sorry to say, but still

internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module './gulpfile'
Require stack:
- C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\index.js:9:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\carsten\\AppData\\Roaming\\nvm\\v12.13.0\\node_modules\\premail\\index.js'
  ]
}

The issue isn't related to nvm, is it? Let me know what you need to trace things down please. I will try to help then.

@CBoensel
Copy link
Author

by the way, it's not just "init" failing... it's just the first thing I tried.

@rootwork
Copy link
Member

First, try uninstalling and reinstalling premail just to make sure there's no old files hanging around:

npm uninstall premail -g
npm cache verify
npm install premail -g

Then just to make sure we're on the same page, please run the following commands and share the output:

node --version
npm --version

Then try running premail -v and sharing that -- but if that gives you the same error, open the file C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\package.json using your editor of choice and tell me what the value next to "version" is.

I'm using n rather than nvm, but I have used nvm in the past and haven't encountered these kinds of issues. Could be a possibility, though.

I'm also noticing the double-backslashes in the requireStack at the very end of the error, and I wonder if this is a cross-platform/Windows thing where path separators aren't being properly parsed. Node is supposed to handle this sort of thing (and in fact as part of the 2.0.4 release I fixed a line where I thought this might be happening) but maybe there's something I've overlooked.

Sorry this is persisting!

@rootwork
Copy link
Member

So I know Windows server != a normal Windows install, but I added a test for Windows to my Node CI and it does appear to install and work on a Windows server (open the "Create a dummy project and build" job; ignore the double-reporting of the files created, I'm working to fix that).

Not saying there couldn't still be cross-platform issues, but it's strange that it installs and runs on the Linux and Windows servers GitHub Actions uses but doesn't work locally.

@CBoensel
Copy link
Author

Thanks.

"version": "2.0.4"

see file attached for logs.

log-carsten-premail.txt

@CBoensel
Copy link
Author

I agree it's weird.

@rootwork
Copy link
Member

@CBoensel Can you tell me if you see the file C:\Users\carsten\AppData\Roaming\nvm\v12.13.0\node_modules\premail\gulpfile.js in your file system (using your console, file explorer, whatever)?

I think the problem might be the ./ when loading the file with require() but I'll have to figure out a more cross-platform way to do that, since just removing it fails and path.join('.', 'gulpfile') doesn't work.

But first let's make sure that file actually exists, and it's just the reference that's bad.

@CBoensel
Copy link
Author

The gulpfile.js does not exist indeed. For whatever reason.

Could I add it manually? Gulp is installed as a global dependency if that matters...

@rootwork
Copy link
Member

You could, but it's far from the only file. I'm still investigating the path possibility, but given that the file doesn't exist I wonder if npm just isn't picking it up. I'll try explicitly adding it to the package.json's "files" list and cut another release.

In the meantime, if you want to test premail, this should work:

git clone https://github.com/premail/premail.git test
cd test
npm i

And then to run premail, you would execute index.js -h. I'm not sure how best to do that on Windows; on Linux or Mac I would do ./index.js -h but I'm not sure if that works on Windows. In any case this is only for testing so you can play around; this wouldn't be a very useful way of running premail normally.

@rootwork
Copy link
Member

OK, try the latest version from npm - 2.0.5. I've explicitly included the gulpfile.js file in the npm package, because I think it wasn't picking it up before. I should have run npm pack before to verify this; that was my fault. Sorry!

@CBoensel
Copy link
Author

Awesome! It's working now, just initialized my first premail project. Thanks for your help. Looking forward to eventually trying things out and templating my mail properly. :) Cheers

@rootwork
Copy link
Member

Excellent! I'm so glad we figured this out.

Please do continue to leave feedback if you find any bugs or want to request features!

@rootwork rootwork added x-Bot: No Changelog This will not be included in automated changelog generation. Status: Done Completed. labels Mar 4, 2022
@rootwork rootwork changed the title support: "premail init" failing "premail init" failing Mar 4, 2022
@github-actions
Copy link

github-actions bot commented Mar 4, 2023

Issue closed and locked due to lack of activity.
If you encounter this same issue, please open a new issue and refer to this closed one.

@github-actions github-actions bot added the Status: Abandoned No activity, considered abandoned. label Mar 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status: Abandoned No activity, considered abandoned. Status: Done Completed. Type: Question Requests for help on how to use the project, or general questions. x-Bot: No Changelog This will not be included in automated changelog generation.
Projects
None yet
Development

No branches or pull requests

2 participants