I have travis-ci
integrated with my GitHub account (https://github.com/pradeep0601/Angular5-Router-App).
When I updated @angular/cli
version from 1.7.4 to 6.0.0-rc.3, the build started failing with an error:
Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
at WorkspaceLoader._getProjectWorkspaceFilePath (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:37:19)
at WorkspaceLoader.loadWorkspace (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:24:21)
at TestCommand._loadWorkspaceAndArchitect (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:177:32)
at TestCommand.<anonymous> (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:45:25)
at Generator.next (<anonymous>)
at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:3:12)
at TestCommand.initialize (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:44:16)
at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/command-runner.js:100:23
package.json snippet to better understand the running environment:
"@angular/cli": "6.0.0-rc.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
This question is related to
angular-cli
travis-ci
package-lock.json
Just check your directory, you must run "ng serve " on the same directory where you have created the project.
So, first enter in your project directory.
Try using the below command:
ng update @angular/cli --migrate-only --from=1.7.4
It will perform the below
Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Pls note that the above command should be run in the folder where you have file .angular-cli.json
and it will be then replaced by angular.json
.
I had the same problem and found that there was no package.json in my project (but only the package-lock.json). I then
..and all worked out fine. Took a while to figure it out, but that did it for me.
With recent version, without --migrate-only
I got the repo updated.
I did ng update
The Angular CLI configuration format has been changed, and your existing configuration can be updated automatically by running the following command:
ng update @angular/cli
Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Some configuration options have been changed, please make sure to update any npm scripts which you may have modified.
DELETE .angular-cli.json
CREATE angular.json (3684 bytes)
UPDATE karma.conf.js (1040 bytes)
UPDATE src/tsconfig.spec.json (322 bytes)
UPDATE package.json (1340 bytes)
UPDATE tslint.json (3140 bytes)
I was trying to set my Ionic 4 app to run as a pwa. When I run the command:
ng add @angular/pwa
...got the error message. After some try and error I discovered that when my project was created the start command was wrong. I was using an Ionic 3 version:
ionic start myApp tabs --type=ionic-angular
And the correct is:
ionic start myApp tabs --type=angular
with no 'ionic-' in type. This solved the error.
Check your folder structure where you are executing the command, you should run the command 'ng serve' where there should be a angular.json file in the structure.
angular.json file will be generated by default when we run the command
npm install -g '@angular/cli' ng new Project_name then cd project_folder then, run ng serve. it worked for me
For people who have simply cloned a project and trying to run it, you need to run npm install
first. I totally forgot to run this and was simply running ng serve
before installing node modules.
I was having this error message inside a docker container. I resolved it adding:
WORKDIR /usr/src
to Dockerfile.
For me what worked was creating a new Angular project and just copied the angular.json file in the project that had a problem due to the fact that the angular.json file was missing.
I also faced same issue and i just executed below command.
ng update @angular/cli --migrate-only --from=1.6.4
It simply delete angular-cli.json
and create angular.json
. You can find this in logs.
Once you start execution. You will be able to see below logs in your terminal.
Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Some configuration options have been changed, please make sure to update any
npm scripts which you may have modified.
DELETE .angular-cli.json
CREATE angular.json (3599 bytes)
UPDATE karma.conf.js (962 bytes)
UPDATE src/tsconfig.spec.json (324 bytes)
UPDATE package.json (1405 bytes)
UPDATE tsconfig.json (407 bytes)
UPDATE tslint.json (3026 bytes)
For me, the issue was that I have an angular project folder inside a rails project folder, and I ran all the angular update commands in the rails parent folder rather than the actual angular folder.
Uninstall the old version of Angular cli, and install Angular CLI global:
Update Angular cli global package to the next version, "@angular/compiler-cli": "^6.0.0"
npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli@next
Generate a new project and default application by running the following command:
ng new my-project
cd my-project
ng serve
I was getting the same error messages. It was a silly mistake on my end, I was not running ng serve
in the directory where my Angular project is. Make sure you are in the correct directory (project directory) before running this command.
If all sorts of updating commando's won't do it. Try deleting package-lock.json. And then run npm install. Did the trick for me after going through tons of update commando's.
It works for me:
Delete folder node_modules
Run command: npm install
( If it does not work for the first time, repeat this 2 or 3 times, Its funny but it works for me. )
Just run ng update @angular/cli
in your console.
You might find some vulnerabilities after running the command (if using npm), but then just runnpm audit fix
in the console to fix them. This command will scan the project for any vulnerabilities and it will also fix compatibility issues by installing updates to these dependencies. If you do not wish to auto fix these vulnerabilities immediately, you can perform a Dry Run: by running npm audit fix --dry-run -json
in the console. This will give you an idea of what the command npm audit fix
will do, in the form of json in the console.
For me the problem was because of global @angular/cli version and @angular/compiler-cli were different. Look into package.json.
...
"@angular/cli": "6.0.0-rc.3",
"@angular/compiler-cli": "^5.2.0",
...
And if they don’t match, update or downgrade one of them.
If you don't know the version ,current project has been made, you can omit --from
command and type --migrate-only
ng update @angular/cli --migrate-only
~/Desktop $ ng serve
Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
at WorkspaceLoader._getProjectWorkspaceFilePath (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:37:19)
at WorkspaceLoader.loadWorkspace (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:24:21)
at ServeCommand._loadWorkspaceAndArchitect (/usr/lib/node_modules/@angular/cli/models/architect-command.js:180:32)
at ServeCommand.<anonymous> (/usr/lib/node_modules/@angular/cli/models/architect-command.js:47:25)
at Generator.next (<anonymous>)
at /usr/lib/node_modules/@angular/cli/models/architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (/usr/lib/node_modules/@angular/cli/models/architect-command.js:3:12)
at ServeCommand.initialize (/usr/lib/node_modules/@angular/cli/models/architect-command.js:46:16)
at Object.<anonymous> (/usr/lib/node_modules/@angular/cli/models/command-runner.js:87:23)
This is because I haven't choose the Angular project directory.
It should be like:
~/Desktop/angularproject $ ng serve
Check out this link to migrate from Angular 5.2 to 6. https://update.angular.io/
Well, I faced the same issue as soon as I updated my angular cli
version.
Earlier I was using 1.7.4 and just now I upgraded it to angular cli 6.0.8
.
To update Angular Cli global:
npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest
To update Angular Cli dev:
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install
To fix audit issues after npm install:
npm audit fix
To fix the issue related to "angular.json":
ng update @angular/cli --migrate-only --from=1.7.4
I had the same problem, and what I did that works for me was:
Inside package.json file, update the Angular CLI version to my desired one:
"devDependencies": { ...
"@angular/cli": "^6.0.8",
...
}
Delete the node_modules
folder, in order to clean the project before update the dependencies with:
npm install
ng update @angular/cli
Try to build again my project (the last and successful attempt)
ng build --prod
Source: Stackoverflow.com