web-dev-qa-db-fra.com

le service échoue avec le fichier d'espace de travail local ('angular.json') introuvable angulaire 5

d'abord je suis dans le bon répertoire

J'ai essayé de servir qui a fonctionné plus tôt aujourd'hui, mais maintenant je reçois les erreurs suivantes: 

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/workspace-loader.js:37:19)
    at WorkspaceLoader.loadWorkspace (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/workspace-loader.js:24:21)
    at ServeCommand._loadWorkspaceAndArchitect (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/architect-command.js:180:32)
    at ServeCommand.<anonymous> (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/architect-command.js:47:25)
    at next (native)
    at /home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/architect-command.js:7:71
    at __awaiter (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/architect-command.js:3:12)
    at ServeCommand.initialize (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/architect-command.js:46:16)
    at Object.<anonymous> (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/models/command-runner.js:87:23)
    at next (native)

alors j'ai couru ng update @angluar/cli --migrate-only --from 1.7.4

Je l'ai fait en suivant la première réponse de ce message de débordement de pile: Erreur: le fichier d'espace de travail local ('angular.json') était introuvable

l'erreur de la mise à jour: 

Error compiling schema, function code: var customRule0 = customRules[0]; var validate = async function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict';  var vErrors = null;  var errors = 0;      if (rootData === undefined) rootData = data;  if ((data && typeof data === "object" && !Array.isArray(data))) {   if (data.force === undefined) data.force =  false ;   if (data.all === undefined) data.all =  false ;   if (data.next === undefined) data.next =  false ;   if (data.migrateOnly === undefined) data.migrateOnly =  false ;   var errs__0 = errors;var valid1 = true; var data1 = data.packages;  if ( data1 === undefined ) { valid1 = true; } else {   var errs_1 = errors; if (Array.isArray(data1)) {   var errs__1 = errors;var valid1;  for (var i1 = 0; i1 < data1.length; i1++) {   var errs_2 = errors; if (typeof data1[i1] !== "string") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.packages[' + i1 + ']' , schemaPath: '#/properties/packages/items/type' , params: { type: 'string' }  , message: 'should be string'  } ]);  }    var valid2 = errors === errs_2;  if (!valid2) break;  }    }  else {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.packages' , schemaPath: '#/properties/packages/type' , params: { type: 'array' }  , message: 'should be array'  } ]);  }  if (errors === errs_1) {   customRule0.errors = null;var errs__1 = errors;var valid1; var customErrors1 = null; try { valid1 = await   customRule0.call( self , data1  , (dataPath || '') + '.packages' , data , 'packages' , rootData )  ; } catch (e) { valid1 = false; if (e instanceof ValidationError) customErrors1 = e.errors; else throw e; }  if (data) data1 = data['packages']; if (  !valid1) {  if (Array.isArray(customErrors1)) { if (vErrors === null) vErrors = customErrors1; else vErrors = vErrors.concat(customErrors1); errors = vErrors.length;  for (var i1=errs__1; i1<errors; i1++) { var ruleErr1 = vErrors[i1]; if (ruleErr1.dataPath === undefined) ruleErr1.dataPath = (dataPath || '') + '.packages';  ruleErr1.schemaPath = "#/properties/packages/$default";   } } else {  throw new ValidationError([ { keyword: '$default' , dataPath: (dataPath || '') + '.packages' , schemaPath: '#/properties/packages/$default' , params: { keyword: '$default' }  , message: 'should pass "$default" keyword validation'  } ]);  }  }    }  var valid1 = errors === errs_1; }  if (valid1) {   var errs_1 = errors; if (typeof data.force !== "boolean") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.force' , schemaPath: '#/properties/force/type' , params: { type: 'boolean' }  , message: 'should be boolean'  } ]);  }    var valid1 = errors === errs_1;  if (valid1) {   var errs_1 = errors; if (typeof data.all !== "boolean") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.all' , schemaPath: '#/properties/all/type' , params: { type: 'boolean' }  , message: 'should be boolean'  } ]);  }    var valid1 = errors === errs_1;  if (valid1) {   var errs_1 = errors; if (typeof data.next !== "boolean") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.next' , schemaPath: '#/properties/next/type' , params: { type: 'boolean' }  , message: 'should be boolean'  } ]);  }    var valid1 = errors === errs_1;  if (valid1) {   var errs_1 = errors; if (typeof data.migrateOnly !== "boolean") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.migrateOnly' , schemaPath: '#/properties/migrateOnly/type' , params: { type: 'boolean' }  , message: 'should be boolean'  } ]);  }    var valid1 = errors === errs_1;  if (valid1) {  if ( data.from === undefined ) { valid1 = true; } else {   var errs_1 = errors; if (typeof data.from !== "string") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.from' , schemaPath: '#/properties/from/type' , params: { type: 'string' }  , message: 'should be string'  } ]);  }    var valid1 = errors === errs_1; }  if (valid1) {  if ( data.to === undefined ) { valid1 = true; } else {   var errs_1 = errors; if (typeof data.to !== "string") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.to' , schemaPath: '#/properties/to/type' , params: { type: 'string' }  , message: 'should be string'  } ]);  }    var valid1 = errors === errs_1; }  if (valid1) {  var data1 = data.registry;  if ( data1 === undefined ) { valid1 = true; } else {   var errs_1 = errors; if (typeof data1 !== "string") {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + '.registry' , schemaPath: '#/properties/registry/type' , params: { type: 'string' }  , message: 'should be string'  } ]);  }   var errs__1 = errors , prevValid1 = false , valid1 = false , passingSchemas1 = null;    var errs_2 = errors;   if (errors === errs_2) {  if (typeof data1 === "string") {    if (!  formats.uri.test(data1) ) {  var err =  { keyword: 'format' , dataPath: (dataPath || '') + '.registry' , schemaPath: '#/properties/registry/oneOf/0/format' , params: { format:  'uri'  }  , message: 'should match format "uri"'  } ;  if (vErrors === null) vErrors = [err]; else vErrors.Push(err); errors++;  }    }  }  var valid2 = errors === errs_2;  if (valid2) { valid1 = prevValid1 = true; passingSchemas1 = 0; }   var errs_2 = errors;   if (errors === errs_2) {  if (typeof data1 === "string") {    if (!  formats.hostname.test(data1) ) {  var err =  { keyword: 'format' , dataPath: (dataPath || '') + '.registry' , schemaPath: '#/properties/registry/oneOf/1/format' , params: { format:  'hostname'  }  , message: 'should match format "hostname"'  } ;  if (vErrors === null) vErrors = [err]; else vErrors.Push(err); errors++;  }    }  }  var valid2 = errors === errs_2;  if (valid2 && prevValid1) { valid1 = false; passingSchemas1 = [passingSchemas1, 1]; } else {  if (valid2) { valid1 = prevValid1 = true; passingSchemas1 = 1; }}if (!valid1) {   var err =    { keyword: 'oneOf' , dataPath: (dataPath || '') + '.registry' , schemaPath: '#/properties/registry/oneOf' , params: { passingSchemas: passingSchemas1 }  , message: 'should match exactly one schema in oneOf'  } ;  if (vErrors === null) vErrors = [err]; else vErrors.Push(err); errors++;  throw new ValidationError(vErrors); } else {  errors = errs__1; if (vErrors !== null) { if (errs__1) vErrors.length = errs__1; else vErrors = null; }  }    var valid1 = errors === errs_1; }  }}}}}}}   }  else {  throw new ValidationError([ { keyword: 'type' , dataPath: (dataPath || '') + "" , schemaPath: '#/type' , params: { type: 'object' }  , message: 'should be object'  } ]);  }    if (errors === 0) return data;            else throw new ValidationError(vErrors);  }; return validate;

ce qui est werid est je n'ai aucune idée comment résoudre ce problème. 

mettre à jour: 

J'ai supprimé package-lock.json puis exécuté npm install puis essayé de servir, puis j'ai reçu la même erreur qu'avant le fait que ma configuration avait changé et que je devais exécuter ng update. 

exécuter la mise à jour et obtenir la même erreur que ci-dessus.

tenté cette correction: 

npm install --save-dev @angular/[email protected]
ng update @angular/cli --migrate-only --from=1.7.4

alors eu cette erreur: 

/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:79
  async run(environment) {
        ^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at module.exports (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/ember-cli/lib/cli/index.js:17:15)
    at default_1 (/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/frontend/suitsandtables/node_modules/@angular/cli/lib/cli/index.js:37:12)
2
user9487981

Cela a fonctionné pour moi avec juste

ng update @angular/cli
2
Andre Rocha

J'ai eu le même problème Souhaitez-vous essayer comme suit: 

npm install -g angular-universal-pwa@beta
ng new --collection angular-universal-pwa myAwesomeApp
cd myAwesomeApp
npm start
0
Wembo Mulumba

Quand le demandeur dit

d'abord je suis dans le bon répertoire

... c'était mon problème.

Vous devriez exécuter ng test dans votre répertoire angulaire.
Si votre projet comporte plusieurs répertoires, assurez-vous de sélectionner le répertoire approprié avant d'exécuter les tests.

0
ANeves