asahasrabuddhe / laravel-mjml

Easily use MJML in your Laravel Blade templates!
MIT License
122 stars 51 forks source link

node is not recognised; but it's installed and available from all consoles. #154

Open mariusberget92 opened 1 year ago

mariusberget92 commented 1 year ago

Hi again. Still having some trouble getting this to work. The error I get is:

The command "node ../node_modules/.bin/mjml D:\Laragon\www\lambda-inertia\storage\framework
\views/5eef33286172620d9fd59fa930e6a35c9a91261383b22ddba6a06b764a0d69ac.mjml.php --config.filePath=D:\Laragon
\www\lambda-inertia\resources\views/emails -o D:\Laragon\www\lambda-inertia\storage\framework
\views/18d7d18a15377d4820fc42047a6c7d749e41c2e5cff55c6380cf251da3e9dc11.php" failed. Exit Code: 1(General error) Working 
directory: D:\Laragon\www\lambda-inertia\public Output: ================ Error Output: ================ 'node' is not
 recognized as an internal or external command, operable program or batch file

I have checked that node is available system wide over all consoles like CMD, PS, Terminal, from the terminal in VSCode even.

Not sure what's causing this.

mariusberget92 commented 1 year ago

After a bit more digging i found that this probably is the the command line that is built is correct, and node is reachable. The error that shows in the back when buildCmdLineFromConfig is run is this:

node D:\Laragon\www\lambda-inertia\node_modules/.bin/mjml D:\Laragon\www\lambda-inertia\storage\framework\views/f6fe8cd79932b131c263b32a01a0238fb75dac0894bd3c12
D:\Laragon\www\lambda-inertia\node_modules\.bin\mjml:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
faridjame commented 1 year ago

Any luck finding out what the issue was? I'm having a similar issue. node is installed and available.

Error I'm receiving on localhost:

The command "node /Applications/MAMP/htdocs/myapp/node_modules/.bin/mjml /Applications/MAMP/htdocs/myapp/storage/framework/views/5b99338279cb5703037f4486d069dd29cc7af9302dfbfa11a81b554d8801c28c.mjml.php --config.filePath=/Applications/MAMP/htdocs/myapp/resources/views/emails -o /Applications/MAMP/htdocs/myapp/storage/framework/views/3cd4fabd56279997dcf1f82f11999697ae299f04bb843d9791039ba6f8d6f2a1.php" failed. Exit Code: 127(Command not found) Working directory: /Applications/MAMP/htdocs/ddmresources/public Output: ================ Error Output: ================ sh: node: command not found

I can copy/paste the exact command in my terminal and it works fine. It just fails when run from the application.

mariusberget92 commented 1 year ago

I did not find the causer sadly. I did just manually generate the mails for now until I find a better solution for MJML.

rodrigo1990 commented 1 year ago

I'm running into the same issue, I have detected that just a breakline can cause the issue: Removing the breakline between

and can make this or to not work.

`

Discount Light Pre-header Text .body-section { -webkit-box-shadow: 1px 4px 11px 0px rgba(0, 0, 0, 0.15); -moz-box-shadow: 1px 4px 11px 0px rgba(0, 0, 0, 0.15); box-shadow: 1px 4px 11px 0px rgba(0, 0, 0, 0.15); } .text-link { color: #5e6ebf } .footer-link { color: #888888 }
<mj-body background-color="#E7E7E7" width="600px">
    <mj-section full-width="full-width" background-color="#040B4F" padding-bottom="0">
        <mj-column width="100%">
            <mj-image src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544153577/Email/Images/AnnouncementOffset/crofts-white.png" alt="" align="center" width="150px" />
            <mj-text color="#ffffff" font-weight="bold" align="center" text-transform="uppercase" font-size="16px" letter-spacing="1px" padding-top="30px">
                Austin, TX
                <br />
                <span style="color: #979797; font-weight: normal">-</span>
            </mj-text>
            <mj-text color="#17CBC4" align="center" font-size="13px" padding-top="0" font-weight="bold" text-transform="uppercase" letter-spacing="1px" line-height="20px">
                Austin Convention Center
                <br />
                123 Main Street, 78701
            </mj-text>
            <mj-image src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544156968/Email/Images/AnnouncementOffset/header-top.png" width="600px" alt="" padding="0" href="https://google.com" />
        </mj-column>
    </mj-section>
    <mj-section background-color="#1f2e78">
        <mj-column width="100%">
            <mj-image src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544156968/Email/Images/AnnouncementOffset/header-bottom.png" width="600px" alt="" padding="0" href="https://google.com" />
        </mj-column>
    </mj-section>
    <mj-wrapper padding-top="0" padding-bottom="0" css-class="body-section">
        <mj-section background-color="#ffffff" padding-left="15px" padding-right="15px">
            <mj-column width="100%">
                <mj-text color="#212b35" font-weight="bold" font-size="20px">
                    Croft's in Austin is opening December 20th
                </mj-text>
                <mj-text color="#637381" font-size="16px">
                    Hi {{$name}},
                </mj-text>
                <mj-text color="#637381" font-size="16px">
                    Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quia a assumenda nulla in quisquam optio quibusdam fugiat perspiciatis nobis, ad tempora culpa porro labore. Repudiandae accusamus obcaecati voluptatibus accusantium perspiciatis.
                </mj-text>
                <mj-text color="#637381" font-size="16px">
                    Tempora culpa porro labore. Repudiandae accusamus obcaecati voluptatibus accusantium perspiciatis:
                </mj-text>
                <mj-text color="#637381" font-size="16px">
                    <ul>
                        <li style="padding-bottom: 20px"><strong>Lorem ipsum dolor:</strong> Sit amet consectetur adipisicing elit.</li>
                        <li style="padding-bottom: 20px"><strong>Quia a assumenda nulla:</strong> Repudiandae accusamus obcaecati voluptatibus accusantium perspiciatis.</li>
                        <li><strong>Tempora culpa porro labore:</strong> In quisquam optio quibusdam fugiat perspiciatis nobis.</li>
                    </ul>
                </mj-text>
                <mj-text color="#637381" font-size="16px" padding-bottom="30px">
                    Lorem ipsum dolor <a class="text-link" href="https://google.com">sit amet consectetur</a> adipisicing elit. Earum eaque sunt nulla in, id eveniet quae unde ad ipsam ut, harum autem porro reiciendis minus libero illo. Vero, fugiat reprehenderit.
                </mj-text>
                <mj-button background-color="#5e6ebf" align="center" color="#ffffff" font-size="17px" font-weight="bold" href="https://google.com" width="300px">
                    RSVP Today
                </mj-button>
                <mj-button background-color="#5e6ebf" align="center" color="#ffffff" font-size="17px" font-weight="bold" href="https://google.com" width="300px">
                    Book an Appointment
                </mj-button>
                <mj-text color="#637381" font-size="16px" padding-top="30px">
                    Lorem ipsum dolor <a class="text-link" href="https://google.com">sit amet consectetur</a> adipisicing elit. Earum eaque sunt nulla in, id eveniet quae unde ad ipsam ut, harum autem porro reiciendis minus libero illo. Vero, fugiat reprehenderit.
                </mj-text>
                <mj-text color="#637381" font-size="16px" padding-bottom="0">
                    Lorem ipsum dolor sit amet consectetur adipisicing elit.
                </mj-text>
            </mj-column>
        </mj-section>
        <mj-section background-color="#ffffff" padding-left="15px" padding-right="15px" padding-top="0">
            <mj-column width="50%">
                <mj-image align="center" src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544153577/Email/Images/AnnouncementOffset/Image_1.png" alt="" />
            </mj-column>
            <mj-column width="50%">
                <mj-image align="center" src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544153578/Email/Images/AnnouncementOffset/Image_2.png" alt="" />
            </mj-column>
        </mj-section>
        <mj-section background-color="#ffffff" padding-left="15px" padding-right="15px" padding-top="0">
            <mj-column width="100%">
                <mj-divider border-color="#DFE3E8" border-width="1px" />
            </mj-column>
        </mj-section>
        <mj-section background-color="#ffffff" padding="0 15px 0 15px">
            <mj-column width="100%">
                <mj-text color="#212b35" font-weight="bold" font-size="20px" padding-bottom="0">
                    Come see us!
                </mj-text>
                <mj-text color="#637381" font-size="16px">
                    We're looking forward to meeting you.
                </mj-text>
            </mj-column>
        </mj-section>
        <mj-section background-color="#ffffff" padding-left="15px" padding-right="15px">
            <mj-column width="50%">
                <mj-text color="#212b35" font-size="12px" text-transform="uppercase" font-weight="bold" padding-bottom="0">
                    address
                </mj-text>
                <mj-text color="#637381" font-size="14px" padding-top="0">
                    Austin Convention Center
                    <br />
                    123 Main Street, 78701
                </mj-text>
            </mj-column>
            <mj-column width="50%">
                <mj-text color="#212b35" font-size="12px" text-transform="uppercase" font-weight="bold" padding-bottom="0">
                    Hours of Operation
                </mj-text>
                <mj-text color="#637381" font-size="14px" padding-top="0">
                    Monday, December 20th: 8:00AM - 5:00PM
                    <br />
                    Tuesday, December 21st: 8:00AM - 5:00PM
                </mj-text>
            </mj-column>
        </mj-section>
        <mj-section background-color="#ffffff" padding-left="15px" padding-right="15px">
            <mj-column width="100%">
                <mj-image src="https://res.cloudinary.com/dheck1ubc/image/upload/v1544153579/Email/Images/AnnouncementOffset/map.jpg" alt="" />
            </mj-column>
        </mj-section>
    </mj-wrapper>

    <mj-wrapper full-width="full-width">
        <mj-section>
            <mj-column width="100%" padding="0">
                <mj-social font-size="15px" icon-size="30px" mode="horizontal" padding="0" align="center">
                    <mj-social-element name="facebook" href="https://mjml.io/" background-color="#A1A0A0">
                    </mj-social-element>
                    <mj-social-element name="google" href="https://mjml.io/" background-color="#A1A0A0">
                    </mj-social-element>
                    <mj-social-element name="twitter" href="https://mjml.io/" background-color="#A1A0A0">
                    </mj-social-element>
                    <mj-social-element name="linkedin" href="https://mjml.io/" background-color="#A1A0A0">
                    </mj-social-element>
                </mj-social>
                <mj-text color="#445566" font-size="11px" font-weight="bold" align="center">
                    View this email in your browser
                </mj-text>
                <mj-text color="#445566" font-size="11px" align="center" line-height="16px">
                    You are receiving this email advertisement because you registered with Croft's Accountants. (123 Main Street, Austin, TX 78701) and agreed to receive emails from us regarding new features, events and special offers.
                </mj-text>
                <mj-text color="#445566" font-size="11px" align="center" line-height="16px">
                    &copy; Croft's Accountants Inc., All Rights Reserved.
                </mj-text>
            </mj-column>
        </mj-section>
        <mj-section padding-top="0">
            <mj-group>
                <mj-column width="100%" padding-right="0">
                    <mj-text color="#445566" font-size="11px" align="center" line-height="16px" font-weight="bold">
                        <a class="footer-link" href="https://www.google.com">Privacy</a>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<a class="footer-link" href="https://www.google.com">Unsubscribe</a>
                    </mj-text>
                </mj-column>
            </mj-group>

        </mj-section>
    </mj-wrapper>

</mj-body>

`

umaraziz0 commented 1 year ago

Hello, I ran across the same issue and managed to find a solution. The error seems to occur only on Windows systems, as the issue didn't occur on unix-based systems like Linux or Mac, or even when I ran it through WSL.

Once you have published the package configuration files using php artisan vendor:publish, you need to add these lines to your .env configuration.

MJML_AUTO_DETECT_PATH=false
MJML_PATH_TO_BINARY=C:\UserName\project-name\node_modules\mjml\bin\mjml

Note: change the above path according to your project path

This will disable the package's auto-detection feature for the mjml js library and replace it with your specified path. Previously, the package might have pointed to C:\UserName\project-name\node_modules\.bin\mjml , which didn't work.

mariusberget92 commented 12 months ago

Hello, I ran across the same issue and managed to find a solution. The error seems to occur only on Windows systems, as the issue didn't occur on unix-based systems like Linux or Mac, or even when I ran it through WSL.

Once you have published the package configuration files using php artisan vendor:publish, you need to add these lines to your .env configuration.

MJML_AUTO_DETECT_PATH=false
MJML_PATH_TO_BINARY=C:\UserName\project-name\node_modules\mjml\bin\mjml

Note: change the above path according to your project path

This will disable the package's auto-detection feature for the mjml js library and replace it with your specified path. Previously, the package might have pointed to C:\UserName\project-name\node_modules\.bin\mjml , which didn't work.

Thank you! :)

engel-m commented 11 months ago

@mariusberget92 This still does not work for me, neither pointing directly to the .bin\mjml or to the \node_modules\mjml\bin\mjml path, I keep getting:

'node' is not recognized as an internal or external command, operable program or batch file.

Can you reopen this issue?

warsemann commented 11 months ago

Hi, i'm on WSL2 and i ve the same problem, when i refresh my test page the file *.mjml.php and another file was created in storage/frameworks/view folder but not the output file. I must run the command in terminal for genaret the output file :(

gnguyo commented 10 months ago

@warsemann Found a solution. Change the binary path to point to the bin folder in the mjml package e.g. image

The issue seems to be caused by node trying to execute a bash file ../node_modules/.bin/mjml. So manually changing the path to lead to the js file will make it work.