sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.32k stars 1.87k forks source link

File not found when building #1686

Closed SOVLOOKUP closed 3 years ago

SOVLOOKUP commented 3 years ago

Describe the bug The build does not run properly, error: no such file or directory

Logs

❯ npm run build

> midway-svelte@0.0.1 build /home/sovlookup/桌面/新建文件夹 (2)/midway-svelte
> svelte-kit build

vite v2.3.7 building for production...
✓ 92 modules transformed.
build/manifest.json                    1.56kb
build/layout.svelte-646c1d37.js        0.49kb / brotli: 0.29kb
build/error.svelte-71b8bb5c.js         1.19kb / brotli: 0.57kb
build/pages/index.svelte-a4c45f6d.js   1.16kb / brotli: 0.57kb
build/assets/start-a8cd1609.css        0.16kb / brotli: 0.10kb
build/chunks/vendor-f965f831.js        18.55kb / brotli: 6.31kb
build/chunks/index-650274ee.js         24.97kb / brotli: 7.49kb
build/start-d1d56062.js                17.18kb / brotli: 5.50kb
> ENOENT: no such file or directory, open '/home/sovlookup/桌面/新建文件夹 (2)/midway-svelte/.svelte-kit/output/client/_app/manifest.json'
Error: ENOENT: no such file or directory, open '/home/sovlookup/桌面/新建文件夹 (2)/midway-svelte/.svelte-kit/output/client/_app/manifest.json'
    at Object.openSync (node:fs:583:3)
    at Object.readFileSync (node:fs:451:35)
    at build_client (file:///home/sovlookup/%E6%A1%8C%E9%9D%A2/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9%20(2)/midway-svelte/node_modules/_@sveltejs_kit@1.0.0-next.115@@sveltejs/kit/dist/chunks/index5.js:354:49)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async build (file:///home/sovlookup/%E6%A1%8C%E9%9D%A2/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9%20(2)/midway-svelte/node_modules/_@sveltejs_kit@1.0.0-next.115@@sveltejs/kit/dist/chunks/index5.js:231:26)
    at async file:///home/sovlookup/%E6%A1%8C%E9%9D%A2/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9%20(2)/midway-svelte/node_modules/_@sveltejs_kit@1.0.0-next.115@@sveltejs/kit/dist/cli.js:648:23
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! midway-svelte@0.0.1 build: `svelte-kit build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the midway-svelte@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sovlookup/.npm/_logs/2021-06-14T02_14_30_601Z-debug.log

To Reproduce

https://github.com/SOVLOOKUP/midway-svelte

Severity

The bug prevents me from deploying the app... Hope it can be resolved soon.

dominikg commented 3 years ago

have you tried to use a project directory with only ascii characters in it ? i suspect this part 桌面/新建文件夹 (2) is not handled correctly either by sveltekit or vite. its either the chinese characters, the space, () or a combination of it, so maybe try removing them one by one to find the culprit

dominikg commented 3 years ago

on second thought, the part .svelte-kit/output/... doesn't look right. I was able to replicate the error with an ascii only path

 ENOENT: no such file or directory, open '/home/dominikg/develop/reproductions/midway-svelte/.svelte-kit/output/client/_app/manifest.json'
Error: ENOENT: no such file or directory, open '/home/dominikg/develop/reproductions/midway-svelte/.svelte-kit/output/client/_app/manifest.json'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at build_client (file:///home/dominikg/develop/reproductions/midway-svelte/node_modules/@sveltejs/kit/dist/chunks/index5.js:354:49)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async build (file:///home/dominikg/develop/reproductions/midway-svelte/node_modules/@sveltejs/kit/dist/chunks/index5.js:231:26)
    at async file:///home/dominikg/develop/reproductions/midway-svelte/node_modules/@sveltejs/kit/dist/cli.js:648:23
npm ERR! code ELIFECYCLE

does midway mess with the build/output config of vite in any way? (not familiar with it at all)

SOVLOOKUP commented 3 years ago

We need @Lxxyx to give some help🤔

Lxxyx commented 3 years ago

@dominikg @SOVLOOKUP

Midway will modify Vite's output directory to build and enable manifest.

You can modify this config at midway.config.ts.

midway.config.ts


import { defineConfig } from '@midwayjs/hooks';

export default defineConfig({ build: { viteOutDir: '' } })



https://github.com/midwayjs/hooks/blob/2d9a9e49678d818327f5ba07dbb393d17392ac24/packages/vite-plugin-hooks/src/plugin.ts#L75-L78
SOVLOOKUP commented 3 years ago

@dominikg @SOVLOOKUP

Midway will modify Vite's output directory to build and enable manifest.

You can modify this config at midway.config.ts.

midway.config.ts


import { defineConfig } from '@midwayjs/hooks';

export default defineConfig({ build: { viteOutDir: '' } })



https://github.com/midwayjs/hooks/blob/2d9a9e49678d818327f5ba07dbb393d17392ac24/packages/vite-plugin-hooks/src/plugin.ts#L75-L78

so i should redirect output to .svelte-kit/output/ ?

Lxxyx commented 3 years ago

so i should redirect output to .svelte-kit/output/ ?

You can try to see if this works

SOVLOOKUP commented 3 years ago

@Lxxyx

You can try to see if this works

It doesn't work, and more strange problems have come up...

To Reproduce: https://github.com/SOVLOOKUP/midway-svelte

Is it possible that the midway/vite-plugin-hooks can work with kit without any extra config?

Lxxyx commented 3 years ago

@Lxxyx Is it possible that the midway/vite-plugin-hooks can work with kit without any extra config?

The following method will build properly.

import { defineConfig } from '@midwayjs/hooks';

export default defineConfig({
  superjson: true,
  routes: [
    {
      baseDir: 'lambda',
      basePath: '/api',
    },
  ],
  build: {
    viteOutDir: null
  }
} as any);

Thanks for the feedback, I'm considering removing the option to specify viteOutDir in the build to make sure there are no conflicts with other Vite based frameworks