Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mlusas's avatar

Help troubleshooting yarn build issue

I'm trying to deploy to a remote server, and after running yarn build I receive an error: TypeError: Cannot read properties of undefined (reading 'endsWith').

The error stack is:

at isWrappedId (file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:7742:40)
    at Object.resolveId (file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:7951:11)
    at file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/rollup/dist/es/shared/rollup.js:23704:40
    at async PluginDriver.hookFirstAndGetPlugin (file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/rollup/dist/es/shared/rollup.js:23604:28)
    at async resolveId (file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/rollup/dist/es/shared/rollup.js:22547:26)
    at async ModuleLoader.loadEntryModule (file:///home/subserver.cloudwaysapps.com/serverid/private_html/releases/20230124064416/node_modules/rollup/dist/es/shared/rollup.js:23156:33)
    at async Promise.all (index 1)

I'm having difficulty troubleshooting this, and Google searches have not been helpful. Any thoughts in what I could do to find the problem?

Thank you.

0 likes
10 replies
Sinnbeck's avatar

What version of node are you running?

Vite requires Node.js version 14.18+, 16+

mlusas's avatar

@Sinnbeck , thank you for the quick response.

node -v is 18.13.0

yarn -v is 1.22.19

yarn vite -v is 4.0.4

Sinnbeck's avatar

@mlusas I seem to recall some people having issues with node 18+ and vite. What version are you running locally? (I could remember wrong)

mlusas's avatar

@Sinnbeck I'm running the same versions, but I'm using sail up to run the code on my dev environment, and that's working. But if I try to run npm build or yarn build, I get the same error as on production.

From what I can gather, it seems that there may be an import with incorrect capitalization (someone said they had something similar with using SVG instead of svg. I'm tediously going through everything right now to see if that's the case, but I'm wondering if there's anything else I should check.

Sinnbeck's avatar

@mlusas Ah ok :) Yeah it can be a bit tricky to find the error when it works with dev. It can also be a some package that uses require, which rollup does not support with the default config. That broke for me once :)

Sadly unless one of your files or packages are in that stacktrace, it is really hard to nail down. I personally use npm to build, but I assume that gives the same error

I notice you wrote npm build instead of npm run build ? Was that a typo?

mlusas's avatar

@Sinnbeck Good catch, yes, it's a typo. Both npm run build and yarn build both return the same error with unhelpful stacktrace.

I just checked all the svg and component capitalization in the project, and it's looking good. Quite frustrating.

Thank you for your help. I've committed to not going to sleep until I resolve this... hopefully, it's not a long night. I'll post if / when I figure this out.

Sinnbeck's avatar

@mlusas As you are running sail, would it be possible to add a new container with node 16 just as a test? :) No guarantee it will fix it, but shouldnt take many minutes to test out

mlusas's avatar
mlusas
OP
Best Answer
Level 4

@Sinnbeck That's a good idea. However, I just confirmed a fix. But definitely good if someone else runs into a similar situation.

In commenting out line by line through vite.config.js, I found the issue was the commented out [require("tailwindcss")]. I seems to have gotten there through some init for Tailwindcss, but was the culprit. Once commented out, everything worked.

Thank you again for your quick responses; it helped to have someone to bounce ideas off of. All the best.

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                './resources/sass/app.scss',
                './resources/js/app.js'
                // [require("tailwindcss")],
            ],
            refresh: true,
        }),
Sinnbeck's avatar

@mlusas That is weird how that ended up there :) But yeah that shouldnt be there

Please or to participate in this conversation.