nrwl / nx

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

Error: Project '1' could not be found in workspace. #525

Closed abnersouza closed 6 years ago

abnersouza commented 6 years ago

Hey guys, trying to run after the nx update all good, but after trying to run the project i got the following error:

Project '1' could not be found in workspace.
Error: Project '1' could not be found in workspace.
    at Workspace.getProject (/app/node_modules/@angular-devkit/core/src/workspace/workspace.js:83:19)
    at Architect.getBuilderConfiguration (/app/node_modules/@angular-devkit/architect/src/architect.js:96:41)
    at runSingleTarget (/app/node_modules/@angular/cli/models/architect-command.js:123:89)
    at ServeCommand.<anonymous> (/app/node_modules/@angular/cli/models/architect-command.js:131:34)
    at Generator.next (<anonymous>)
    at /app/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/@angular/cli/models/architect-command.js:3:12)
    at ServeCommand.runArchitectTarget (/app/node_modules/@angular/cli/models/architect-command.js:121:16)
    at ServeCommand.<anonymous> (/app/node_modules/@angular/cli/commands/serve.js:34:25)

Any idea on how to solve the issue?

Thanks, Abner

jschwarty commented 6 years ago

@abnersouza What command did you run that resulted in this error? ng serve? And can you provide a repo/example or maybe your angular.json file? Thanks! 😄

vt5491 commented 6 years ago

Same problem. Got around it by specifying the target name on the build command directly and specifying --configuration instead of --environment:

old: ng serve --environment=my_env --host 0.0.0.0

new: ng serve myApp --configuration my_env --host 0.0.0.0

Basically, I directly specified my app name 'myApp' directly after 'ng serve'

vt5491 commented 6 years ago

Basically there's a bogus projetctName of '1' in projectNames. I put in some prints in workspace.js:

vturner@vturner-virtual-machine ~/vtstuff/github2/vrgal $ ng serve  --environment=val --host 0.0.0.0 --ssl 1 --ssl-key ~/vtstuff/certs/localhost.key --ssl-cert ~/vtstuff/certs/localhost.crt
vt.workspace.js.getProject: projectName=vrgal
vt.workspace.js.getProject: projectName=vrgal
vt.workspace.js.getProject: projectName=vrgal-e2e
vt.workspace.js.getProject: projectName=1
Project '1' could not be found in workspace.
Error: Project '1' could not be found in workspace.
    at Workspace.getProject (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular-devkit/core/src/workspace/workspace.js:84:19)
    at Architect.getBuilderConfiguration (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular-devkit/architect/src/architect.js:96:41)
    at runSingleTarget (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/models/architect-command.js:123:89)
    at ServeCommand.<anonymous> (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/models/architect-command.js:131:34)
    at Generator.next (<anonymous>)
    at /home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/models/architect-command.js:3:12)
    at ServeCommand.runArchitectTarget (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/models/architect-command.js:121:16)
    at ServeCommand.<anonymous> (/home/vturner/vtstuff/github2/vrgal/node_modules/@angular/cli/commands/serve.js:34:25)

my angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "vrgal": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico",
              "src/.htaccess"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [
              "src/assets/libs/wasd-plus-controls.js",
              "src/assets/libs/aframe/sticky-state.js",
              "src/assets/libs/aframe/save-state.js",
              "src/assets/libs/aframe/system-base.js",
              "src/assets/libs/aframe/system-utils.js",
              "src/assets/libs/grab-vt.js",
              "src/assets/libs/aframe/hand-controls-vt.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            },
            "sea": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.sea.ts"
                }
              ]
            },
            "val": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.val.ts"
                }
              ]
            },
            "ec2": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.ec2.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "vrgal:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "vrgal:build:production"
            },
            "sea": {
              "browserTarget": "vrgal:build:sea"
            },
            "val": {
              "browserTarget": "vrgal:build:val"
            },
            "ec2": {
              "browserTarget": "vrgal:build:ec2"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "vrgal:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "src/assets/libs/wasd-plus-controls.js",
              "src/assets/libs/aframe/sticky-state.js",
              "src/assets/libs/aframe/save-state.js",
              "src/assets/libs/aframe/system-base.js",
              "src/assets/libs/aframe/system-utils.js",
              "src/assets/libs/grab-vt.js",
              "src/assets/libs/aframe/hand-controls-vt.js"
            ],
            "styles": [
              "src/styles.css"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico",
              "src/.htaccess"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "vrgal-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "vrgal:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "vrgal",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}
abnersouza commented 6 years ago

@vt5491 Thanks, I will try do the same in my project.

vsavkin commented 6 years ago

@abnersouza could you provide a repo with a repro?

abnersouza commented 6 years ago

@vsavkin Unfortunately I decide not to update for the moment, I will try what @vt5491 suggested as soon as I can, many libs we use haven't updated to Angular 6 yet.

Yonet commented 6 years ago

@abnersouza you can reopen when you can provide a repro. I will close the issue. Thanks!

ceccomil commented 6 years ago

... --ssl true ... instead of --ssl 1 should solve the issue.

abnersouza commented 6 years ago

@ceccomil It really fix the issue thanks a lot, but now i have the issue with command to run command: ng serve -a=admin -p=3200 --aot --host 0.0.0.0 --ssl true --ssl-key cert/key.pem --ssl-cert cert/cert.pem

where -a=admin is app name i have three different apps, also is complaining about -p=3000

ceccomil commented 6 years ago

@abnersouza my guess is, this question it's not related to an issue it's more a request on how to do something... anyway if you run "ng serve --help" you can see the list of available options and change what you need accordingly eg. -p=3200 --port 3200

jamshed-qureshi-mobinext commented 5 years ago

I solved it by replacing the project name to the one mentioned in package.json file & it worked for me.

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.