WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Having error while Creating build for the Gutenberg. #54486

Open NidhiDhandhukiya74 opened 1 year ago

NidhiDhandhukiya74 commented 1 year ago

Description

I have cloned the Gutenberg Repository. Whenever I tried to create build I got the below error :-

error TS6053: File 'Sites/demosites/app/public/wp-content/plugins/gutenberg/packages/core-data/build-types/index.d.ts' not found. The file is in the program because: Root file specified for compilation error TS6231: Could not resolve the path '/Users/nidhimeetshah/Local' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation

Step-by-step reproduction instructions

Followed this steps :- $ git clone https://github.com/YOUR_GITHUB_USERNAME/gutenberg.git $ cd gutenberg $ git remote add upstream https://github.com/WordPress/gutenberg.git npm install npm run dev

Screenshots, screen recording, code snippet

CleanShot 2023-09-15 at 08 58 10@2x

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

doubleedesign commented 9 months ago

I had this issue too, and part of it was that I had a space in the file path - "Local Sites" (I'm using Local by Flywheel). This looks like the same or a very similar situation.

Once I solved that though (by removing the space and symlinking Local Sites > LocalSites so I don't have to change anything else) I am still getting other "incorrect published types" errors so it's not a complete fix. I'm on Windows if it matters, but using Bash not CMD.

doubleedesign commented 9 months ago

In addition to making sure my file path doesn't contain spaces as per the above comment, I was able to get my build working with a number of workarounds including bumping versions for dependencies mentioned in the error messages and some tsconfig tweaks. When that got me most of the way but not 100% solved, I simply removed the check from the build:package-types step and for the small amount of time I've been working with it, it seems to be working fine like this.

I haven't created a PR for it because I haven't done sufficient testing to work out exactly which part(s) of my workaround are helpful and if any aren't necessary, and I can't be confident that there aren't any unintended consequences, but I wanted to share it here in case it helps someone else or with a future fix. I forked the repo at the v17.5.2 release and this commit contains the changes that allow my fork to build at the time of writing.

ETA: You also must ensure that whichever terminal you are using is aware of where Python is installed. In my case, I also had some install and build issues that were because I assumed Python was fine, but because I was using Bash not CMD I actually needed to add an alias to my Bash config defining where Python is. Having it in my PATH in the system environment variables had no effect for Bash. None of the error messages indicated that this is the cause, so I wanted to come back and note it.