naxodev / oss

Open Source Software (OSS) projects by naxodev
https://naxo.dev
MIT License
19 stars 1 forks source link

[nx-cloudflare] Getting multiple warnings when I run my project with `serve` command #36

Closed mnlbox closed 5 months ago

mnlbox commented 5 months ago

Current Behavior

When I run my project through the serve command I'm getting this warning in my terminal:

ā–² [WARNING] kj/filesystem-disk-unix.c++:1709: warning: PWD environment variable doesn't match current directory; pwd = /mnlbox

Expected Behavior

It's a bit annoying as it prints two warning each time the server reload so it's a bit noisy in the terminal. Should I ignore it or it's a bug on the serve command? Or maybe my project structure is not correct? šŸ¤”

GitHub Repo

No response

Steps to Reproduce

  1. Create my project with this command:

    pnpm nx generate @naxodev/nx-cloudflare:application --name api-test--template hono --directory apis/test --port 4001 --projectNameAndRootFormat=as-provided
  2. Then run my project with this command:

    pnpm nx serve api-test

My project is run successfully and I can see the Hello Hono! message in the browser when I visit: http://localhost:4001 But I'm getting two warning like this:

 ā›…ļø wrangler 3.48.0
-------------------
ā–² [WARNING] kj/filesystem-disk-unix.c++:1709: warning: PWD environment variable doesn't match current directory; pwd = /mnlbox

[wrangler:inf] Ready on http://localhost:4001
āŽ” Starting local server...
ā–² [WARNING] kj/filesystem-disk-unix.c++:1709: warning: PWD environment variable doesn't match current directory; pwd = /mnlbox

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.11.0
OS     : linux-arm64
pnpm   : 8.15.5

nx                 : 18.2.4
@nx/js             : 18.2.4
@nx/jest           : 18.2.4
@nx/linter         : 18.2.4
@nx/eslint         : 18.2.4
@nx/workspace      : 18.2.4
@nx/devkit         : 18.2.4
@nx/esbuild        : 18.0.6
@nx/eslint-plugin  : 18.2.4
@nx/nest           : 18.2.4
@nx/node           : 18.2.4
@nx/playwright     : 18.2.4
@nx/react          : 18.2.4
@nrwl/tao          : 18.2.4
@nx/vite           : 18.2.4
@nx/web            : 18.2.4
@nx/webpack        : 18.2.4
typescript         : 5.4.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/vite/plugin
@nx/playwright/plugin
---------------------------------------
Community plugins:
@naxodev/nx-cloudflare : 2.0.1
---------------------------------------
The following packages should match the installed version of nx
  - @nx/esbuild@18.0.6
  - @nrwl/esbuild@18.0.6

To fix this, run `nx migrate nx@18.2.4`

Failure Logs

No response

Operating System

Additional Information

I'm using vscode devContainer with a Debian based linux in a MacOs host machine.

mnlbox commented 5 months ago

And BTW as I checked the NX report now I think the @nx/esbuild package is installed by @naxodev/nx-cloudflare package to build the cloudflare function but it seems the version is not matched based on this section of NX report:

The following packages should match the installed version of nx
  - @nx/esbuild@18.0.6
  - @nrwl/esbuild@18.0.6

Maybe it's better to have these packages as as peerDependencies or maybe just update them in the generator.

NachoVazquez commented 5 months ago

Hey @mnlbox, thanks for the thorough issue!

Regarding the warning, this is very likely coming from Wrangler. You can verify that by running wrangler dev directly on the application folder. This serve executor wraps over it.

Regarding the version mismatch, that's a good catch, so I'll have it fixed.

mnlbox commented 5 months ago

Thanks @NachoVazquez for your quick answer. I tried to run the app via Wrangler as you suggested from the application folder:

cd apis/test
pnpm wrangler dev

I also tried to call it from the root of my monorepo like this:

pnpm wrangler dev apis/test/src/index.ts

And I didn't get any warnings in the terminal and the app is running on the default port of Wrangler. So I guess something is wrong with the baseUrl of the serve command maybe we need to set it based on the value of directory parameter in the generator. šŸ¤”

mnlbox commented 5 months ago

And BTW, one more small suggestion: I guess it's useful to add the project website url to the NPM page here as well: https://www.npmjs.com/package/@naxodev/nx-cloudflare

I had to search and find this repo from your GitHub profile to report this issue as there was no website available on the NPM page of the nx-cloudflare package.

And thanks for this awesome and useful project. I like it ā¤ļø It's a good idea to organize all of the tiny Cloudflare Worker projects in an NX monorepo. šŸ˜‰

NachoVazquez commented 5 months ago

Hey, thanks for that! That means a lot. I have a lot of plans for this project, starting by adding more application templates. Time has been short on my side lately.

And thanks for letting me know about the npm URL. That's not helping. I will also dig deeper into the warning you are getting.

NachoVazquez commented 5 months ago

I was able to reproduce your issue; it should be easier to address now.

NachoVazquez commented 5 months ago

I know what the problem is. We need to set the cwd on the forked thread to aim for the project folder, but that's not the matching of the pwd, which is the project's root. It does seem to change the PWD env variable, however.

NachoVazquez commented 5 months ago

Manually setting the process.env.PWD seems to work.

mnlbox commented 5 months ago

@NachoVazquez Thanks for your support. I'll fix it whenever you release it and update you here šŸ˜‰

NachoVazquez commented 5 months ago

I'll release this changes with the fixes to the deploy/publish command