Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'nx/src/utils/app-root' #632

Open
Jeff-Stapleton opened this issue Jun 10, 2022 · 25 comments
Open

Cannot find module 'nx/src/utils/app-root' #632

Jeff-Stapleton opened this issue Jun 10, 2022 · 25 comments

Comments

@Jeff-Stapleton
Copy link

I am trying to create an NX monorepo for an ionic react app I am building.

I create the nx workspace like so:
npx create-nx-workspace my-org --preset=empty

Then I installed installed the required dependencies:
npm install --save-dev --exact @nxtend/ionic-react @nxtend/capacitor @nrwl/react

Finally I am trying to generate my ionic-react app using the following command:
nx generate @nxtend/ionic-react:application myApp

However I am getting the following error:

>  NX  Generating @nxtend/ionic-react:application

✔ Which starter template would you like to use? · tabs
Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/@nxtend/ionic-react/node_modules/@nrwl/devkit/index.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/@nxtend/ionic-react/src/generators/application/generator.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/nx/src/config/workspaces.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/nx/src/command-line/generate.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/nx/src/command-line/nx-commands.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/nx/bin/init-local.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/nx/bin/nx.js
- /Users/jeffstapleton/Documents/Github/integrations-front-end/node_modules/@nrwl/cli/bin/nx.js
- /Users/jeffstapleton/.nvm/versions/node/v14.15.0/lib/node_modules/nx/node_modules/@nrwl/cli/bin/nx.js
- /Users/jeffstapleton/.nvm/versions/node/v14.15.0/lib/node_modules/nx/bin/nx.js

For the sake of being thurough I will include my entire package.json here in case the problem is with my specific version:

{
  "name": "integrations-front-end",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "start": "nx serve",
    "build": "nx build",
    "test": "nx test"
  },
  "private": true,
  "dependencies": {
    "@capacitor/core": "3.5.1",
    "@ionic/react-router": "6.1.9",
    "@testing-library/jest-dom": "5.16.4",
    "@testing-library/react": "13.3.0",
    "@testing-library/user-event": "14.2.0",
    "@types/jest": "28.1.1",
    "@types/node": "17.0.41",
    "@types/react": "18.0.12",
    "@types/react-dom": "18.0.5",
    "@types/react-router": "5.1.18",
    "@types/react-router-dom": "5.3.3",
    "ionicons": "6.0.2",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-router": "6.3.0",
    "react-router-dom": "6.3.0",
    "react-scripts": "5.0.1",
    "typescript": "4.7.3",
    "web-vitals": "2.1.4",
    "workbox-background-sync": "6.5.3",
    "workbox-broadcast-update": "6.5.3",
    "workbox-cacheable-response": "6.5.3",
    "workbox-core": "6.5.3",
    "workbox-expiration": "6.5.3",
    "workbox-google-analytics": "6.5.3",
    "workbox-navigation-preload": "6.5.3",
    "workbox-precaching": "6.5.3",
    "workbox-range-requests": "6.5.3",
    "workbox-routing": "6.5.3",
    "workbox-strategies": "6.5.3",
    "workbox-streams": "6.5.3",
    "@ionic-native/core": "5.36.0",
    "@ionic-native/splash-screen": "5.36.0",
    "@ionic-native/status-bar": "5.36.0",
    "@ionic/react": "6.1.9",
    "@nrwl/workspace": "14.2.4"
  },
  "devDependencies": {
    "@capacitor/android": "3.5.1",
    "@capacitor/cli": "3.5.1",
    "@capacitor/ios": "3.5.1",
    "@nrwl/cli": "14.2.4",
    "@nrwl/cypress": "14.2.4",
    "@nrwl/eslint-plugin-nx": "14.2.4",
    "@nrwl/jest": "14.2.4",
    "@nrwl/linter": "14.2.4",
    "@nrwl/nx-cloud": "latest",
    "@nrwl/react": "^14.2.4",
    "@nrwl/tao": "14.2.4",
    "@nrwl/workspace": "14.2.4",
    "@nxtend/capacitor": "^13.0.0",
    "@nxtend/ionic-react": "^13.0.0",
    "nx": "14.2.4",
    "prettier": "2.6.2",
    "typescript": "4.7.2"
  }
}

@0x1ad2
Copy link

0x1ad2 commented Jun 14, 2022

Hi @Jeff-Stapleton! I'm encountering the exact same problem.

I tried to apply the solutions mentioned here, but no luck so far nrwl/nx#4731

Could you paste your report here, using npx nx report you can generate it, here is mine:

 Node : 16.15.0
   OS   : darwin x64
   npm  : 8.5.5
   
   nx : 14.2.4
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.2.4
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.2.4
   @nrwl/eslint-plugin-nx : 14.2.4
   @nrwl/express : Not Found
   @nrwl/jest : 14.2.4
   @nrwl/js : 14.2.4
   @nrwl/linter : 14.2.4
   @nrwl/nest : Not Found
   @nrwl/next : 14.2.4
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.2.4
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.2.4
   @nrwl/web : 14.2.4
   @nrwl/workspace : 14.2.4
   typescript : 4.7.3
   ---------------------------------------
   Community plugins:
         @nxtend/capacitor: 13.0.0

@0x1ad2
Copy link

0x1ad2 commented Jun 14, 2022

Alright so you probably have to options

  • Roll back to @nxtend/capacitor version 12.1.0
  • cd inside your container directory and run npx cap --help to find what you could do without downgrading @nxtend/capacitor

@rjlopezdev
Copy link

Same issue here with cap sync command.
This happens since I upgrade to Nx v^14.x.x

@Applicafroguy
Copy link

Applicafroguy commented Jun 15, 2022

Same issue for angular

Node : 16.14.0
OS   : linux x64
yarn : 1.22.19

nx : 14.3.3
@nrwl/angular : 14.3.3
@nrwl/cypress : 14.3.3
@nrwl/detox : Not Found
@nrwl/devkit : 14.3.3
@nrwl/eslint-plugin-nx : 14.3.3
@nrwl/express : Not Found
@nrwl/jest : 14.3.3
@nrwl/js : 14.3.3
@nrwl/linter : 14.3.3
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 14.3.3
@nrwl/nx-cloud : 14.1.1
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.3.3
@nrwl/web : Not Found
@nrwl/workspace : 14.3.3
typescript : 4.7.3
---------------------------------------
Community plugins:
	 rxjs: 6.6.7
	 @nxtend/capacitor: 13.0.0
	 @nxtend/ionic-angular: 13.1.0
	 @storybook/angular: 6.5.9

@Stevoohh
Copy link

Same issue. Any progress on this ?

Cannot find module 'nx/src/utils/app-root'

@mtiahrt
Copy link

mtiahrt commented Jun 16, 2022

same problem with Angular also. Tried version 12 and it also didn't work for me.

@Tam2
Copy link

Tam2 commented Jun 16, 2022

Downgrading back to 14.1.7 works

@dandouglas
Copy link

Same issue here

Node : 14.17.0
   OS   : darwin arm64
   npm  : 6.14.13
   
   nx : 14.3.6
   @nrwl/angular : 14.3.6
   @nrwl/cypress : 14.3.6
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.3.6
   @nrwl/eslint-plugin-nx : 14.3.6
   @nrwl/express : Not Found
   @nrwl/jest : 14.3.6
   @nrwl/js : 14.3.6
   @nrwl/linter : 14.3.6
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.1.3
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.3.6
   @nrwl/web : 14.3.6
   @nrwl/workspace : 14.3.6
   typescript : 4.6.4
   ---------------------------------------
   Community plugins:
         @nxtend/capacitor: 13.0.0

@dandouglas
Copy link

Thanks @Tam2 downgrading to 14.1.7 did indeed work. Hopefully this issue will be fixed soon 🤞

@nkl3in
Copy link

nkl3in commented Jul 7, 2022

@dandouglas, @Tam2 - did you downgrade nx and all plugins to 14.1.7? And did you use the nx version migration, or did you just change the versions by hand? Asking because this fix did not work for me.

edit:
In my case I had to heed the warning and downgrade nx to ^13.0.0.

> npm i -D @nxtend/cpacitor
npm WARN @nxtend/capacitor@13.0.0 requires a peer of @nrwl/workspace@^13.0.0 but none is installed. You must install peer dependencies yourself

@dandouglas
Copy link

@dandouglas, @Tam2 - did you downgrade nx and all plugins to 14.1.7? And did you use the nx version migration, or did you just change the versions by hand? Asking because this fix did not work for me.

I downgraded NX and all the @nrwl plugins by hand 👍

@SimonPrammer
Copy link

SimonPrammer commented Jul 9, 2022

Any updates on this? Unable to create a ionic workspace with nxtend as well.

@Destreyf
Copy link

This is the same issue as #628 and there's a pull request #638 to address this, but no sign yet from the owner of the repo of getting this merged.

Downgrading to 14.1.7 isn't really an option for me at this time, so I am unable to use the currently released version of nxtend.

it looks like #633 is also affected by nx higher than 14.1.X.

I do not know if PR #638 covers the issues here and in #633 so there may need to be more changes to handle the different versions between 14.1, 14.2, 14.3, and 14.4.

@SimonPrammer
Copy link

For me downgrading NX did not solve the issue. Neither 13.0.0 nor 14.1.7 seemed to do the trick.

@mackelito
Copy link

Thanks @Tam2 downgrading to 14.1.7 did indeed work. Hopefully this issue will be fixed soon 🤞

What steps did you take to downgrade?
Looking at doing the same and don't want to miss anything :)

@Tam2
Copy link

Tam2 commented Jul 20, 2022

I manually changed the versions in package.json to 14.1.7, deleted the node_modules folder and then ran npm install

@mackelito
Copy link

I manually changed the versions in package.json to 14.1.7, deleted the node_modules folder and then ran npm install

And that would be all @nrwl/* packages?

@Tam2
Copy link

Tam2 commented Jul 20, 2022

Yes, this is what it looks like:

nx : 14.1.7
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.1.4
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.4
   @nrwl/eslint-plugin-nx : 14.1.7
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.4
   @nrwl/js : 14.1.7
   @nrwl/linter : 14.1.7
   @nrwl/nest : 14.1.7
   @nrwl/next : Not Found
   @nrwl/node : 14.1.7
   @nrwl/nx-cloud : 14.1.1
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 14.1.7
   typescript : 4.7.3
   rxjs : 7.5.5
   ---------------------------------------
   Community plugins:
         @nxext/svelte: 14.0.0
         @nxext/sveltekit: 14.0.0-next.02

@muuvmuuv
Copy link

muuvmuuv commented Jul 20, 2022

For anyone that want a patch, here. This also includes #633.

Details
diff --git a/src/executors/run-commands/run-commands.impl.js b/src/executors/run-commands/run-commands.impl.js
index d2c45a4405755b63e541b060f0e7631781f33b9c..052e0a4c172454d8c3cfae567739baa5fc1e3be6 100644
--- a/src/executors/run-commands/run-commands.impl.js
+++ b/src/executors/run-commands/run-commands.impl.js
@@ -190,7 +190,7 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
         return command.replace(regex, (_, group) => opts.parsedArgs[group]);
     }
     else if (forwardAllArgs) {
-        return `${command}${opts.__unparsed__.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
+        return `${command}${opts.__unparsed__?.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
     }
     else {
         return command;
diff --git a/src/utils/app-root.d.ts b/src/utils/app-root.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..9d8d8966d6d98539c395ce6d7c95333f7ab35474
--- /dev/null
+++ b/src/utils/app-root.d.ts
@@ -0,0 +1,11 @@
+/**
+ * The root of the workspace.
+ *
+ * @deprecated use workspaceRoot instead
+ */
+export declare const appRootPath: string;
+/**
+ * The root of the workspace
+ */
+export declare const workspaceRoot: string;
+export declare function fileExists(filePath: string): boolean;
diff --git a/src/utils/app-root.js b/src/utils/app-root.js
new file mode 100644
index 0000000000000000000000000000000000000000..440e99787ed3facbe77e036f17d7f49ff90789cb
--- /dev/null
+++ b/src/utils/app-root.js
@@ -0,0 +1,39 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fileExists = exports.workspaceRoot = exports.appRootPath = void 0;
+const path = require("path");
+const fs_1 = require("fs");
+/**
+ * The root of the workspace.
+ *
+ * @deprecated use workspaceRoot instead
+ */
+exports.appRootPath = pathInner(__dirname);
+/**
+ * The root of the workspace
+ */
+exports.workspaceRoot = exports.appRootPath;
+function pathInner(dir) {
+    if (process.env.NX_WORKSPACE_ROOT_PATH)
+        return process.env.NX_WORKSPACE_ROOT_PATH;
+    if (path.dirname(dir) === dir)
+        return process.cwd();
+    if (fileExists(path.join(dir, 'workspace.json')) ||
+        fileExists(path.join(dir, 'nx.json')) ||
+        fileExists(path.join(dir, 'angular.json'))) {
+        return dir;
+    }
+    else {
+        return pathInner(path.dirname(dir));
+    }
+}
+function fileExists(filePath) {
+    try {
+        return (0, fs_1.statSync)(filePath).isFile();
+    }
+    catch (err) {
+        return false;
+    }
+}
+exports.fileExists = fileExists;
+//# sourceMappingURL=app-root.js.map
\ No newline at end of file
diff --git a/src/utils/app-root.js.map b/src/utils/app-root.js.map
new file mode 100644
index 0000000000000000000000000000000000000000..d8068dc95b667de1d6c5f5af8d2fd616ed328f97
--- /dev/null
+++ b/src/utils/app-root.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/app-root.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,2BAA8B;AAE9B;;;;GAIG;AACU,QAAA,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AAEhD;;GAEG;AACU,QAAA,aAAa,GAAG,mBAAW,CAAC;AAEzC,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;QACpC,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACpD,IACE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACrC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAC1C;QACA,OAAO,GAAG,CAAC;KACZ;SAAM;QACL,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KACrC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,IAAI;QACF,OAAO,IAAA,aAAQ,EAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;KACpC;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gCAMC"}
\ No newline at end of file

How?

  • pnpm
    • copy contents into a file patches/nx@14.4.3.patch
    • add to package.json "pnpm": { "patchedDependencies": { "nx@14.4.3": "patches/nx@14.4.3.patch" } }
    • pnpm install
  • yarn
  • npm
    • no support

@orl99
Copy link

orl99 commented Jul 21, 2022

How and where can I apply this patch?

@muuvmuuv
Copy link

@orl99 I have updated my answer. But have a look at yarn or pnpm
https://pnpm.io/cli/patch

@mackelito
Copy link

For anyone that want a patch, here. This also includes #633.

Details
How?

  • pnpm

    • copy contents into a file patches/nx@14.4.3.patch
    • add to package.json "pnpm": { "patchedDependencies": { "nx@14.4.3": "patches/nx@14.4.3.patch" } }
    • pnpm install
  • yarn

  • npm

    • no support

Would https://www.npmjs.com/package/patch-package work?

@ntgussoni
Copy link

For anyone that want a patch, here. This also includes #633.

Details
How?

  • pnpm

    • copy contents into a file patches/nx@14.4.3.patch
    • add to package.json "pnpm": { "patchedDependencies": { "nx@14.4.3": "patches/nx@14.4.3.patch" } }
    • pnpm install
  • yarn

  • npm

    • no support

Thanks a lot! This worked for us

@SimonPrammer
Copy link

Still waiting for an "official" fix.
Would be great to at least get some message if it will be looked into.

@devinshoemaker
Copy link
Collaborator

These plugins are moving over to the Nxext repo, and an Nx 14 version has been released. There are some migration guides on their docs site, here's a link to the Ionic Angular guide: https://nxext.dev/docs/ionic-angular/migrating-from-nxtend.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests