prisma / nuxt-prisma

Prisma ORM integration for Nuxt
https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/prisma-nuxt-module
32 stars 2 forks source link

prisma studio start error #13

Closed 1034935767 closed 1 week ago

1034935767 commented 1 week ago

I got this error. I use windows,.

async function installStudio(directory) {
  try {
    const { spawn } = require("child_process");
    log(PREDEFINED_LOG_MESSAGES.installStudio.action);
    await spawn("npx", ["prisma", "studio", "--browser", "none"], {
      cwd: directory,
      shell: true // when use windows, this should be add 
    });
    logSuccess(PREDEFINED_LOG_MESSAGES.installStudio.success);
    return true;
  } catch (err) {
    logError(PREDEFINED_LOG_MESSAGES.installStudio.error);
    log(err);
    return false;
  }
}
ERROR  [uncaughtException] spawn npx ENOENT                                                            09:51:02  

  at ChildProcess._handle.onexit (node:internal/child_process:286:19)
  at onErrorNT (node:internal/child_process:484:16)
  at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
bbhxwl commented 1 week ago

I can run it, but I cannot build it

jharrell commented 1 week ago

Duplicate of #12

JohanManders commented 10 hours ago

I just want to mention that this added line does fix the issue, which I also encounter with a fresh install of Nuxt on Windows.

bbhxwl commented 10 hours ago

I just want to mention that this added line does fix the issue, which I also encounter with a fresh install of Nuxt on Windows.

What specific line of code is it? My English is not good.

JohanManders commented 10 hours ago

I temporary fixed it by adding shell: true to node_modules\@prisma\nuxt\dist\module.mjs:

async function installStudio(directory) {
  try {
    const { spawn } = require("child_process");
    log(PREDEFINED_LOG_MESSAGES.installStudio.action);
    await spawn("npx", ["prisma", "studio", "--browser", "none"], {
      cwd: directory,
      shell: true // when use windows, this should be add 
    });
    logSuccess(PREDEFINED_LOG_MESSAGES.installStudio.success);
    return true;
  } catch (err) {
    logError(PREDEFINED_LOG_MESSAGES.installStudio.error);
    log(err);
    return false;
  }
}

I hope an OS check gets added, to add this line is someone uses Windows.

Thanks to @1034935767

bbhxwl commented 10 hours ago

I temporary fixed it by adding shell: true to node_modules\@prisma\nuxt\dist\module.mjs:

async function installStudio(directory) {
  try {
    const { spawn } = require("child_process");
    log(PREDEFINED_LOG_MESSAGES.installStudio.action);
    await spawn("npx", ["prisma", "studio", "--browser", "none"], {
      cwd: directory,
      shell: true // when use windows, this should be add 
    });
    logSuccess(PREDEFINED_LOG_MESSAGES.installStudio.success);
    return true;
  } catch (err) {
    logError(PREDEFINED_LOG_MESSAGES.installStudio.error);
    log(err);
    return false;
  }
}

I hope an OS check gets added, to add this line is someone uses Windows.

Thanks to @1034935767

Where is this added to? I am different from you. I made an error using the drone CI CD, and I did not make any mistakes while developing on Windows.