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

missing config file docu #303

Closed
freshfx opened this issue Jun 15, 2016 · 12 comments
Closed

missing config file docu #303

freshfx opened this issue Jun 15, 2016 · 12 comments

Comments

@freshfx
Copy link

freshfx commented Jun 15, 2016

Hi,

I have a problem on generating a template with the cli using custom components.

I initialized a new component with the cli command mjml --init-component <name>.
This command will create a new folder with the component in ES6 style. I used babel to generate an ES5 javascript and move the file to ./components/image-link.
Now i want to generate a template using the new component. I created a .mjmlconfig file in my project root path with this content

{
  "packages": [
    "./components/image-link.js"
  ]
}

I always get this error message

Warning: .mjmlconfig file ./components/image-link.js has an error : Error: Cannot find module './components/image-link.js'

Can you please tell me the right way to use custom components with the cli. (A short example/how-to would be awesome)

@iRyusa
Copy link
Member

iRyusa commented Jun 15, 2016

Hello @freshfx ,

Can you provide results of this commands : pwd, ls -l, node -v and the code inside image-link.js

@freshfx
Copy link
Author

freshfx commented Jun 15, 2016

i'm using Node v6.2.1

here is the content of the image-link.js
https://gist.github.com/freshfx/1de3853390fcf3bbe72dcd057c80b1ea

the project structure

project
|-- .babelrc
|-- .mjmlconfig
|-- .nvmrc
|-- package.json
|-- bin
|-- `-- generate
|-- components
|   `-- image-link.js
|-- mails
|   `-- test.mjml
`-- dist

in my package.json is a start script which execute the ./bin/generate script.
And this script does mjml -r ./mails/test.mjml -o ./dist/test.html
And thats the point i get the error.

@iRyusa
Copy link
Member

iRyusa commented Jun 15, 2016

Can you try to set the full path instead of relative to see if it works ?

@freshfx
Copy link
Author

freshfx commented Jun 15, 2016

it works with full path. but it would be much nicer, if the path can be relative too.

@iRyusa
Copy link
Member

iRyusa commented Jun 15, 2016

It might be a working directory issue from the process mjml mhh i'll add some debug information for further investigation

@freshfx
Copy link
Author

freshfx commented Jun 16, 2016

awesome. thanks.

@iRyusa
Copy link
Member

iRyusa commented Jul 11, 2016

2.3 has been released, it should gives you more informations when it happens

@alex-e-leon
Copy link

alex-e-leon commented Jul 24, 2016

@iRyusa I'm having the same issue on v2.3
The error message I'm getting is

Warning: .mjmlconfig file ./new-component/src/index.js opened from ~/mjml-dir has an error : Error: Cannot find module './new-component/src/index.js'

Replacing the path in .mjmlconfig with an absolute path fixes the issue for me

@iRyusa
Copy link
Member

iRyusa commented Jul 25, 2016

Does the working directory new-component is inside mjml-dir ?

I wonder if this is an issue on the npm package but not on the dev installed version

@alex-e-leon
Copy link

@iRyusa Yeap, it could be an issue with the published version. new-component is inside mjml-dir

@vbraun
Copy link

vbraun commented Aug 4, 2016

I have the same issue. Need to use

 NODE_PATH=. mjml mails/test.mjml

to pick up the module.

@iRyusa iRyusa reopened this Aug 8, 2016
@iRyusa iRyusa modified the milestones: 2.4.0, 2.3 Aug 8, 2016
@iRyusa
Copy link
Member

iRyusa commented Oct 18, 2016

Hello there,

MJML 3 come with a refactor of .mjmlconfig it should now parse absolute path correctly ! Feel free to test it and give us some feedback 👍

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

No branches or pull requests

4 participants