GithubHelp home page GithubHelp logo

Comments (4)

kentcdodds avatar kentcdodds commented on April 20, 2024

Looks like it's trying to find an executable at C:\Users\myname\Code\blues-stack-test\node which is quite odd. Just to confirm something for me though, could you run all these scripts in separate terminals? This will help us make sure this is a pm2 issue.

node --inspect --require .\node_modules\dotenv\config --require .\mocks .\build\server.js
npm run build:server -- --watch
npx remix watch
npm run generate:css -- --watch

Let me know if that works. If so, then we know this is a pm2 issue.

from blues-stack.

jakexconniff avatar jakexconniff commented on April 20, 2024

Yeah it looks like all 4 scripts are working in separate terminals. In order, here is the output from the terminals in case it is ever relevant:

$ node --inspect --require .\node_modules\dotenv\config --require .\mocks .\build\server.js
Debugger listening on ws://127.0.0.1:9229/dadba26d-186a-4f72-a4c3-2ebfc3f049df
For help, see: https://nodejs.org/en/docs/inspector
� Mock server running
(node:19060) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
� setting up prisma client to localhost:5432
✅ app ready: http://localhost:3000
$ npm run build:server -- --watch

> build:server
> esbuild --platform=node --format=cjs ./server.ts --outdir=build "--watch"

[watch] build finished, watching for changes...
$ npx remix watch
Watching Remix app in development mode...
� Built in 693ms
� File changed: app\styles\tailwind.css
� Rebuilding...
� Rebuilt in 227ms
$ npm run generate:css -- --watch

> generate:css
> tailwindcss -o ./app/styles/tailwind.css "--watch"


Rebuilding...
Done in 286ms.

from blues-stack.

kentcdodds avatar kentcdodds commented on April 20, 2024

Yeah, so this looks like just a matter of pm2 doing something weird with the node script, but it appears to be fine with npm scripts, so maybe try the latest push I just made where I moved it into an npm script: 89bb536

from blues-stack.

OriginalEXE avatar OriginalEXE commented on April 20, 2024

Hi,

I ran into the same issue, it's pm2 related, happens only on Windows and there are no non-hacky solutions it seems. You can read more about the issue here: Unitech/pm2#3657

TL;DR; For some weird reason, pm2 on Windows assumes that whatever you pass to script inside of the apps array of your pm2.config.json is a path to a file, rather than a command (even though it properly supports that same command when you run it as a single command). So my approach is to actually create files for each of those commands and then use shelljs package to spawn shells which run the actual commands.

I have fixed it by doing the following:

  1. Change /other/pm2.config.js to:
const env = {
  NODE_ENV: process.env.NODE_ENV ?? "development",
  FORCE_COLOR: "1",
};

module.exports = {
  apps: [
    {
      name: "Server",
      script: "./other/server.js",
      watch: ["./mocks/**/*.ts", "./build/server.js", "./.env"],
      env,
    },
    {
      name: "Server Build",
      script: "./other/server-build.js",
      ignore_watch: ["."],
      env,
    },
    {
      name: "Remix",
      script: "./other/remix.js",
      ignore_watch: ["."],
      env,
    },
    {
      name: "Tailwind",
      script: "./other/tailwind.js",
      autorestart: false,
      ignore_watch: ["."],
      env,
    },
  ],
};
  1. Create /other/server.js with the following:
var shell = require("shelljs");

shell.exec("npm run dev:server", { windowsHide: true });
  1. Create /other/server-build.js with the following:
var shell = require("shelljs");

shell.exec("npm run build:server -- --watch", { windowsHide: true });
  1. Create /other/remix.js with the following:
var shell = require("shelljs");

shell.exec("npx remix watch", { windowsHide: true });
  1. Create /other/tailwind.js wit the following:
var shell = require("shelljs");

shell.exec("npm run generate:css -- --watch", { windowsHide: true });

Your npm run dev should now work as expected.

from blues-stack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.