nuxtr-vscode icon indicating copy to clipboard operation
nuxtr-vscode copied to clipboard

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

Open MartinTruRating opened this issue 2 years ago • 12 comments

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

MartinTruRating avatar Sep 21 '23 14:09 MartinTruRating

Hello @MartinTruRating,

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

adhamfarrag avatar Sep 21 '23 15:09 adhamfarrag

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

0vn avatar Sep 22 '23 05:09 0vn

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

adhamfarrag avatar Sep 23 '23 01:09 adhamfarrag

@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

MartinTruRating avatar Sep 28 '23 11:09 MartinTruRating

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

adhamfarrag avatar Sep 28 '23 14:09 adhamfarrag

@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

MartinTruRating avatar Oct 02 '23 08:10 MartinTruRating

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

adhamfarrag avatar Oct 02 '23 16:10 adhamfarrag

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 :)

MartinTruRating avatar Oct 03 '23 11:10 MartinTruRating

@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.

adarsh4d avatar Oct 18 '23 06:10 adarsh4d

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

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

RihanArfan avatar Oct 22 '23 18:10 RihanArfan

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...

XStarlink avatar Mar 13 '24 10:03 XStarlink