nuxtrdev / nuxtr-vscode

An extension offering commands and tools to make your experience with Nuxt more pleasant.
https://marketplace.visualstudio.com/items?itemName=Nuxtr.nuxtr-vscode
338 stars 13 forks source link

[Bug]: Extension doesn't work when nuxt project is in a sub folder of the workspace #49

Open MartinTruRating opened 1 year ago

MartinTruRating commented 1 year ago

Environment

Nuxt project info:


What went wrong?

I was trying to use nuxtr when my nuxt project lives within a subfolder within the workspace (ie /src). But it cannot find it (see below

image

Is there a config setting that allows it to set the root dir of nuxtr so it can then pick everything up and work?

I tried using the monorepo DirectoryName config setting set to /src which enabled the extension and worked for things like creating components/stores etc but didn't for installing deps because it was trying to use the workspace root which is correct for a monorepo setup.

How to reproduce it?

Install nuxt into a subfolder structure like this: image

Nuxtr isn't available in the sidebar or command pallete

adhamfarrag commented 1 year ago

Hello @MartinTruRating,

To be clear, your issue now is not being able to install dependencies ? Also, /src dir has your whole Nuxt logic ?

0vn commented 1 year ago

I encountered the same problem, when Workspace mode is enabled, Nuxtr recognizes the first item in the workspace by default, and when my project is not ranked first in the workspace, Nuxtr does not recognize the item I need, and currently I can only fix this problem when I move my project to the first place

adhamfarrag commented 1 year ago

@Administrator-M can you elaborate more about "my project is not ranked first in the workspace" ?

MartinTruRating commented 1 year ago

@adhamfarrag Hello, yeah so the /src has everything in it from .nuxt folder to node_modules folder etc. But because the vscode editor is opened at the parent level above /src it would try to install packages at that level (if I enabled workspace mode).

It's like we need a combination of the two in a setting where you can specifiy the rootDir or something for where nuxtr starts working from

adhamfarrag commented 1 year ago

@MartinTruRating have you tried using "nuxtr.monorepoMode.DirectoryName": "src" ?

MartinTruRating commented 1 year ago

@adhamfarrag I did, so that then worked (as in I could use it to create components etc), but the problem then was when I tried to install/update any dependencies, it tried doing it in the folder above the src folder (which in a monorepo setup would be fine as the modules get installed into the root) rather than within the /src folder.

I've added the following rough directory structure if this helps at all

$root
 - .vscode
 - other root files
 - src (where the main app lives)
 - - .nuxt
 - - components
 - - composables
 - - node_modules
adhamfarrag commented 1 year ago

Got it.. I will refactor monorepo features and release it as soon as I can.

MartinTruRating commented 1 year ago

Brilliant, thank you very much! Make sure you still keep the monorepo functionality/compatibility for those that want to use that feature as I've used it on different projects :)

adarsh4d commented 1 year ago

@adhamfarrag Thanks for your awesome work on this!

To add more info regarding the issue faced by @Administrator-M, when we create Multi-root Workspaces if the first folder has a different project, then all the features provided by Nuxtr are not available.

For example, if the multi-root workspace is like this, it works image

However, this doesn't work image

The reason for using this approach is both has different language/framework and have their own source control. They are just grouped using the multi-root workspace approach to avoid switching windows.

RihanArfan commented 1 year ago

Experiencing the same issue. Here's my project structure:

├───apps
│   ├───application1
│   └───application2
└───packages
    └───base
XStarlink commented 8 months ago

Experiencing the same issue. Here's my project structure:

├───apps
│   ├───application1
│   └───application2
└───packages
    └───base

I have the same structure, and I'd love to use Nuxtr with the file creation templates it offers, but in my monorepo it won't activate...