'Is there a way convert the root package into a npm workspace

I have a project structure like:

projectx (root)
 - package.json
 - componentsOfRoot
 - packages   
 -- components1
   -- src
   -- package.json (name: @projectx/components1, scripts: "dev":"ts-node or whatever")

I know from the root folder I can set components1 as a workspace, but my question is can I convert/set projectx (root) itself into a workspace?

I want to import inside components1 something that belongs to projectx (root), eg:

//inside components1 > MyComponent.jsx
import {componentsOfRoot} from "@myScope/projectx"

Is that possible? How?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source