Angular CLI: 6.0.1
Node: 6.11.4
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/core 0.6.1
@angular-devkit/schematics 0.6.1
@schematics/angular 0.6.1
@schematics/update 0.6.1
rxjs 6.1.0
typescript 2.7.2
$ npm install -g @angular/cli$ ng new MY-PROJECTAs soon as I execute $ ng new MY-PROJECT I get this error:
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;
Unexpected token function
Working Angular project creation :)
The angular-cli was using an older version of Node.
Actually, I had 2 different versions installed on my machine, so $ node -v was giving me a diffierent version that $ ng version.
I had the same error with Node v6.10.2 installed. I updated Node to the version 10.1.0, and the error is gone.
I got this exact error with v6.11.4 when I had node_modules in the parent directory. Simply moving it away fixed the problem.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I had the same error with Node v6.10.2 installed. I updated Node to the version 10.1.0, and the error is gone.