question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run most nx commands from CLI or from NxConsole

See original GitHub issue

Current Behavior

Started going through the basic nx tutorial (https://nx.dev/angular/tutorial/01-create-application). I have been able to launch the app (via ./node_modules/.bin/nx serve todos) from a regular terminal (outside of VSCode), but then I tried to do the same thing with NxConsole in VSCode. I selected the serve command, specified the “todos” project, changed no defaults, and pressed run. That precipitated this error:

> Executing task: ng serve todos <

Now using node v12.13.1 (npm v6.12.1)

> ng run todos:serve 
/Users/msorens/code/sandbox/myorg/node_modules/@nrwl/cli/lib/run-cli.js:13
    if (workspace.type === 'nx') {
                  ^

TypeError: Cannot read property 'type' of null
    at requireCli (/Users/msorens/code/sandbox/myorg/node_modules/@nrwl/cli/lib/run-cli.js:13:19)
    at Object.<anonymous> (/Users/msorens/code/sandbox/myorg/node_modules/@nrwl/cli/lib/run-cli.js:9:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11
The terminal process "/usr/local/bin/bash '-l', '-c', '/Users/msorens/code/sandbox/myorg/node_modules/.bin/ng serve todos', 'ng serve todos'" terminated with exit code: 1.

Expected Behavior

Should successfully serve the app with no error. Not a regression; first time I am trying NxConsole.

Steps to Reproduce

Cloned the nx-examples repo; did npm install, then npm start outside of VSCode, and it compiled successfully. Inside VSCode with NxConsole, I selected the serve command, specified the “products” project, changed no defaults, and pressed run. Here I received a different error:

> Executing task: ng serve products <

Now using node v12.13.1 (npm v6.12.1)
An invalid configuration file was found ['/Users/msorens/code/sandbox/nx-examples/angular.json']. Please delete the file before running the command.
The terminal process "/usr/local/bin/bash '-l', '-c', '/Users/msorens/code/sandbox/nx-examples/node_modules/.bin/ng serve products', 'ng serve products'" terminated with exit code: 1.

I deleted angular.json as specified and then attempted to rerun again, and got this:

> Executing task: ng serve products <

Now using node v12.13.1 (npm v6.12.1)
The serve command requires to be run in an Angular project, but a project definition could not be found.

Failure Logs

NA

Environment

This is running on MacOs 10.14.6

VSCode details: Version: 1.49.1 Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf Date: 2020-09-16T23:21:17.533Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 18.7.0

nx report details: @nrwl/angular : 9.5.1 @nrwl/cli : 9.5.1 @nrwl/cypress : 9.5.1 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 9.5.1 @nrwl/linter : Not Found @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 9.5.1 @nrwl/web : Not Found @nrwl/workspace : 9.5.1 typescript : 3.8.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
Frikkicommented, Nov 27, 2020

That this issue has been left uncommented for 60+ days by the maintainers of the library screams to newcomers, “DON’T USE NX!”

0reactions
github-actions[bot]commented, Mar 29, 2021

This issue has been automatically marked as stale because it hasn’t had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nx CLI run many command is not working for multiple apps
Try this: nx run-many --parallel --target=serve --projects=frontend,backend.
Read more >
nx: command not found error [Solved] | bobbyhadz
If the "nx: command not found" error is not resolved, try restarting your terminal. If that doesn't help, run the following command: shell....
Read more >
@nrwl/workspace:run-commands | Nx
Run any custom commands with Nx. Options can be configured in project. json when defining the executor, or when invoking it.
Read more >
Nx Console - Visual Studio Marketplace
The UI for Nx & Lerna. Spend less time looking up command line arguments and more time shipping incredible products.
Read more >
Building Full-Stack Applications Using Angular CLI and Nx
An app is something that we can run, either in the browser or on the server. Often building an app creates an optimized...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found