nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.28k stars 2.32k forks source link

Cannot find module 'nx/src/utils/app-root' with local installation of nx , version 14.3.5 #10776

Closed phlukman closed 2 years ago

phlukman commented 2 years ago

hi ,

I'm getting an error message when trying to build the project, using nx 14.3.5, that it can't find the module "Cannot find module 'nx/src/utils/app-root'"

I'm installing npm 8.11.0, and installing nx locally. Any hints?

AgentEnder commented 2 years ago

What's nx report say? app-root was removed a few minor versions back.

seryl commented 2 years ago

I actually have the same issue; here's it with a fresh project:

> npx create-nx-workspace@latest remix \
                            --preset=@nrwl/remix \
                            --project=website
Need to install the following packages:
  create-nx-workspace@latest
Ok to proceed? (y) y
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

 >  NX   Nx is creating your v14.3.6 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✖ Creating your workspace

 >  NX   Nx failed to create a workspace.

   Exit code: 1
   Log file: /var/folders/k9/4ssyf5w11bj1dz1kq17c6zv80000gn/T/tmp-3670-5DXw2szxRW6Z/error.log

The error log:

> cat /var/folders/k9/4ssyf5w11bj1dz1kq17c6zv80000gn/T/tmp-3670-5DXw2szxRW6Z/error.log

>  NX  Generating @nrwl/workspace/generators.json:new

CREATE remix/README.md
CREATE remix/.editorconfig
CREATE remix/.gitignore
CREATE remix/.prettierignore
CREATE remix/.vscode/extensions.json
CREATE remix/workspace.json
CREATE remix/nx.json
CREATE remix/package.json
CREATE remix/tools/generators/.gitkeep
CREATE remix/tools/tsconfig.tools.json
CREATE remix/tsconfig.base.json
CREATE remix/.prettierrc
CREATE remix/apps/.gitkeep
CREATE remix/libs/.gitkeep

added 1182 packages, and audited 1183 packages in 19s

152 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

>  NX  Generating @nrwl/remix:preset

npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/jtoft/Desktop/remix/node_modules/@nrwl/devkit/index.js
- /Users/jtoft/Desktop/remix/node_modules/@nrwl/remix/src/generators/preset/preset.impl.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/config/workspaces.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/command-line/generate.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/command-line/nx-commands.js
- /Users/jtoft/Desktop/remix/node_modules/nx/bin/init-local.js
- /Users/jtoft/Desktop/remix/node_modules/nx/bin/nx.js
Workspace creation failed, see above.

And finally the nx report:

> ./node_modules/.bin/nx report

 >  NX   Report complete - copy this into the issue template

   Node : 18.2.0
   OS   : darwin arm64
   npm  : 8.9.0

   nx : 14.3.6
   @nrwl/angular : Not Found
   @nrwl/cypress : 13.10.5
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.5
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.5
   @nrwl/js : 13.10.5
   @nrwl/linter : 13.10.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 13.10.5
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.5
   @nrwl/web : 13.10.5
   @nrwl/workspace : 14.3.6
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
     @nrwl/remix: 14.1.7
seryl commented 2 years ago

I have a feeling it's related to the @nrwl/* versions being so old: 13.10.5 vs 14.3.6.

BeniTheDuke commented 2 years ago

deleting the "node_modules" folder before npm install solved the problem for me

riencoertjens commented 2 years ago

same issue for me @AgentEnder do you need any more info than given above?

davecoffin commented 2 years ago

Also having this problem:

Require stack:
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/@nrwl/devkit/index.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/@nativescript/nx/src/executors/build/builder.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/@angular-devkit/architect/node/index.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/nx/src/adapter/ngcli-adapter.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/nx/src/command-line/run.js
- /Users/davecoffin/Develop/presonus/mypxplat/node_modules/nx/bin/run-executor.js
dandouglas commented 2 years ago

Any news on this? I have the same issue since migrating to the latest NX.

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:
         @compodoc/compodoc: 1.1.19
         @fortawesome/angular-fontawesome: 0.9.0
         @ionic/angular: 6.1.12
         @ionic/angular-toolkit: 2.3.3
         @ngneat/spectator: 8.3.2
         @ngrx/component: 13.2.0
         @ngrx/effects: 13.2.0
         @ngrx/router-store: 13.2.0
         @ngrx/store: 13.2.0
         @ngrx/store-devtools: 13.2.0
         @nxtend/capacitor: 13.0.0
         @nxtend/ionic-angular: 13.1.0
         @storybook/angular: 6.4.22
         apollo-angular: 2.6.0
         ng-mocks: 12.5.1
         rxjs: 6.6.3
AgentEnder commented 2 years ago

Your versions appear in sync, most likely one of the community plugins uses that deep import and the file location moved. You'd need to drill into it and figure out which one and open the issue there.

dandouglas commented 2 years ago

Thanks for the quick reply. Your correct it looks to be related to the @nxtend/capacitor plugin and I can see an open issue for it.

halbekanne commented 2 years ago

I have the same problem. Is this related to having nx version 14 but having @nrwl/* version 13? I want to stay on version 13 with Angular for the time being, is there a way to fix this without updating everything to latest?

ng report

Node : 16.16.0
   OS   : win32 x64
   npm  : 8.11.0

   nx : 14.4.2
   @nrwl/angular : 13.10.6
   @nrwl/cypress : 13.10.6
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.6
   @nrwl/eslint-plugin-nx : 13.10.6
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.6
   @nrwl/js : Not Found
   @nrwl/linter : Not Found
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.6
   @nrwl/web : Not Found
   @nrwl/workspace : 13.10.6
   typescript : 4.6.3
   ---------------------------------------
   Community plugins:
         rxjs: 6.6.7
FlurryNight commented 2 years ago

I actually have the same issue; here's it with a fresh project:

> npx create-nx-workspace@latest remix \
                            --preset=@nrwl/remix \
                            --project=website
Need to install the following packages:
  create-nx-workspace@latest
Ok to proceed? (y) y
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

 >  NX   Nx is creating your v14.3.6 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✖ Creating your workspace

 >  NX   Nx failed to create a workspace.

   Exit code: 1
   Log file: /var/folders/k9/4ssyf5w11bj1dz1kq17c6zv80000gn/T/tmp-3670-5DXw2szxRW6Z/error.log

The error log:

> cat /var/folders/k9/4ssyf5w11bj1dz1kq17c6zv80000gn/T/tmp-3670-5DXw2szxRW6Z/error.log

>  NX  Generating @nrwl/workspace/generators.json:new

CREATE remix/README.md
CREATE remix/.editorconfig
CREATE remix/.gitignore
CREATE remix/.prettierignore
CREATE remix/.vscode/extensions.json
CREATE remix/workspace.json
CREATE remix/nx.json
CREATE remix/package.json
CREATE remix/tools/generators/.gitkeep
CREATE remix/tools/tsconfig.tools.json
CREATE remix/tsconfig.base.json
CREATE remix/.prettierrc
CREATE remix/apps/.gitkeep
CREATE remix/libs/.gitkeep

added 1182 packages, and audited 1183 packages in 19s

152 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

>  NX  Generating @nrwl/remix:preset

npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/jtoft/Desktop/remix/node_modules/@nrwl/devkit/index.js
- /Users/jtoft/Desktop/remix/node_modules/@nrwl/remix/src/generators/preset/preset.impl.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/config/workspaces.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/command-line/generate.js
- /Users/jtoft/Desktop/remix/node_modules/nx/src/command-line/nx-commands.js
- /Users/jtoft/Desktop/remix/node_modules/nx/bin/init-local.js
- /Users/jtoft/Desktop/remix/node_modules/nx/bin/nx.js
Workspace creation failed, see above.

And finally the nx report:

> ./node_modules/.bin/nx report

 >  NX   Report complete - copy this into the issue template

   Node : 18.2.0
   OS   : darwin arm64
   npm  : 8.9.0

   nx : 14.3.6
   @nrwl/angular : Not Found
   @nrwl/cypress : 13.10.5
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.5
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.5
   @nrwl/js : 13.10.5
   @nrwl/linter : 13.10.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 13.10.5
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.5
   @nrwl/web : 13.10.5
   @nrwl/workspace : 14.3.6
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
       @nrwl/remix: 14.1.7

Exactly the same on a fresh project, latest versions and same error

AgentEnder commented 2 years ago

Packages are not tested with different versions, and things may and do break. This is an example of such a change. If you need to keep @nrwl/angular on v13, you'd need to keep the rest of the repo on the same versions too.

@ZR3SYSTEMS Looking at your report, most packages are on 13.10.5 while @nrwl/workspace is on 14.3.6, this would cause the error.

AgentEnder commented 2 years ago

I'm going to close this out since the cause has been identified and next steps provided

Your correct it looks to be related to the @nxtend/capacitor plugin and I can see an open issue for it.

FlurryNight commented 2 years ago

Packages are not tested with different versions, and things may and do break. This is an example of such a change. If you need to keep @nrwl/angular on v13, you'd need to keep the rest of the repo on the same versions too.

@ZR3SYSTEMS Looking at your report, most packages are on 13.10.5 while @nrwl/workspace is on 14.3.6, this would cause the error.

That's a quote reply from what @seryl posted xD, what i wanted to show was that I used the same command to create the workspace and I was using latest versions 14.xx, that was not my output, although the error is the same, even switched node versions

AgentEnder commented 2 years ago

What's nx report show for you?

FlurryNight commented 2 years ago

What's nx report show for you?

$ ./node_modules/.bin/nx report

 >  NX   Report complete - copy this into the issue template

   Node : 18.5.0
   OS   : linux x64
   npm  : 8.12.1

   nx : 14.4.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 13.10.6
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.6
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.6
   @nrwl/js : 13.10.6
   @nrwl/linter : 13.10.6
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 13.10.6
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.6
   @nrwl/web : 13.10.6
   @nrwl/workspace : 14.4.2
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
         @nrwl/remix: 14.1.7
AgentEnder commented 2 years ago

There are several packages on different versions there, which is not supported

FlurryNight commented 2 years ago

There are several packages on different versions there, which is not supported

Well okay, but how should i solve this if I used npx create-nx-workspace@latest


$ npx create-nx-workspace@latest remix --preset=@nrwl/remix  --project=website
Need to install the following packages:
  create-nx-workspace@14.4.2
Ok to proceed? (y) y
✔ Set up distributed caching using Nx Cloud (It's free and doesn't require registration.) · No

 >  NX   Nx is creating your v14.4.2 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✖ Creating your workspace

 >  NX   Nx failed to create a workspace.

   Exit code: 1
   Log file: /tmp/tmp-117108-X4ydjwC8NNdE/error.log
AgentEnder commented 2 years ago

I can't speak to the remix preset, its possible that it is not currently working with latest. You should file an issue at https://github.com/nrwl/nx-labs if that is the case.

FlurryNight commented 2 years ago

Okay! yeah, that's it -> https://github.com/nrwl/nx-labs/issues/85

Thanks

ThePlenkov commented 2 years ago

I don't know if it makes sense - but for me deleting node_modules didn't work. But what worked - is yarn instead of npm i

ThePlenkov commented 2 years ago

ok yarn is not the reason. it was just different version resolution logic. The actual fix is delivered within 14.5.8 version. In 14.5.6 the bug still existed.

shirakaba commented 2 years ago

I got this due to having two different projects that each wanted a different version of nx.

This happened when I was trying to manually set up both NativeScript and React Native in the same nx workspace. I'd started with the NativeScript template and then attempted integrating React Native into it manually by studying the React Native Nx starter template.

Here was my initial report, when I was facing this error:

➜  nativescript-magic-spells git:(repo-restructure) ✗ ./node_modules/.bin/nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.17.0
   OS   : darwin arm64
   yarn : 1.22.18

   nx : 14.4.0
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.6.4
   @nrwl/detox : 14.6.4
   @nrwl/devkit : 14.6.4
   @nrwl/eslint-plugin-nx : 14.4.0
   @nrwl/express : Not Found
   @nrwl/jest : 14.6.4
   @nrwl/js : 14.6.4
   @nrwl/linter : 14.6.4
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.4.0
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.6.4
   @nrwl/react-native : 14.6.4
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.6.4
   @nrwl/web : 14.6.4
   @nrwl/workspace : 14.6.4
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
         @nativescript/plugin-tools: 4.0.1

Using yarn why nx, I found that @nativescript/plugin-tools had an exact dependency (no caret or tilde) on @nrwl/workspace@14.4.0 and thus indirectly on nx@14.4.0.

To fix things, I downgraded the React Native side of things to the same nx version as NativeScript was using by running yarn add -D @nrwl/react-native@14.4.0. Now my report looks like this:

➜  nativescript-magic-spells git:(repo-restructure) ✗ ./node_modules/.bin/nx report        

 >  NX   Report complete - copy this into the issue template

   Node : 16.17.0
   OS   : darwin arm64
   yarn : 1.22.18

   nx : 14.4.0
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.4.0
   @nrwl/detox : 14.4.0
   @nrwl/devkit : 14.4.0
   @nrwl/eslint-plugin-nx : 14.4.0
   @nrwl/express : Not Found
   @nrwl/jest : 14.4.0
   @nrwl/js : 14.4.0
   @nrwl/linter : 14.4.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.4.0
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.4.0
   @nrwl/react-native : 14.4.0
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.4.0
   @nrwl/web : 14.4.0
   @nrwl/workspace : 14.4.0
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
         @nativescript/plugin-tools: 4.0.1

... and I no longer receive the error mentioned in the issue 🚀

DudiKaplan commented 1 year ago

I upgraded nx to version 15 nx migrate latest everything works for me as it should.

AHMET-EMREBAS commented 1 year ago

Removing nx dependency from the project dependencies solved my problem.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.