Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
213 stars 13 forks source link

ERROR Cannot create Logfolder src/logs #35

Closed ivarlovlie closed 2 years ago

ivarlovlie commented 2 years ago

Setting createLog to true gives me this error on build if the folder src/logs does not already exist:

 ERROR  File: vite-aliases.json could not be created.                                                                                                                                                                                          13:14:19

 ERROR  Error: ENOENT: no such file or directory, open 'src/logs/vite-aliases.json'                                                                                                                                                            13:14:19

  at abort (node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.js:5277:22)
  at writeJSON (node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.js:5296:5)
  at async writeLog (node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.js:5400:5)

 ERROR  Cannot create Logfolder src/logs.                                                                                                                                                                                                      13:14:19

  at abort (node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.js:5277:22)
  at writeLog (node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.js:5402:5)

node:internal/process/promises:265
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
 ELIFECYCLE  Command failed with exit code 1.

Would be nice if we didn't have to create the logs file inside of project src folder, maybe we could just put the vite-aliases.json file adjacent to the vite config file in the project root?

Subwaytime commented 2 years ago

Sounds like a good addition! Right now, vite-aliases should recursively create a folder, but a seperate path as an option might be interesting. I am working on an update atm to fix various issues, so ill include it!

Subwaytime commented 2 years ago

fixed in v0.9.2