Angular-cli: You have to be inside an angular-cli project in order to use the build command.

Created on 20 Jul 2016  Â·  30Comments  Â·  Source: angular/angular-cli

#i run this command 
git add *
git commit -m 'msg'
ng github-pages:deploy --message "Optional commit message"

then error to me :

#ng build
You have to be inside an angular-cli project in order to use the build command.

#ng g component hello
You have to be inside an angular-cli project in order to use the g command.

.....
1 (urgent) bufix

Most helpful comment

I just run into this problem,
Fixed updating angular-cli in this way:

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest

No need to delete the node_modules folder

All 30 comments

Could you explain why this is unexpected? The cli needs to know how the project is configured.

which config file ?

steps:

ng new hello  -> ok
ng g component user -> ok
ng g component .... -> ok
ng serve -> ok
ng build -> ok

git add *
git commit -m 'msg'
ng github-pages:deploy --message "Optional commit message"  -> error => github token no permission
@here looks like delete my src/ dir and many other files , my src source code lost
ng build -> error:
You have to be inside an angular-cli project in order to use the build command.
........

happend again:

ng github-pages:deploy --message "msg"
(node:5689) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
Built project successfully. Stored in "dist/".
fs.js:95
      throw err;  // Forgot a callback but don't know where? Use NODE_DEBUG=fs
      ^

Error: ENOTEMPTY: directory not empty, rmdir 'next/dist/vendor/@angular/platform-browser/src/'

ng github-pages:deploy --message "msg"
ng build
You have to be inside an angular-cli project in order to use the build command.

now files in projects:(no src dir and config files now )

 >ls
404.html         dist             index.html       node_modules     tmp              vendor
app              favicon.ico      main.js          system-config.js typings

> ls dist
app              favicon.ico      index.html       main.js          system-config.js vendor

Hi @WG-Com, it seems like something went wrong in the deploy procedure, namely the error that you got: error => github token no permission.

Sometimes when this happens the repo is left on the gh-pages branch and you need to manually git checkout master. Your code is still there and safe.

I thought That I had picked fixed all scenarios where that happens but it seems there is at least one still. I'll try to fix it.

I realize this item is about a bug, but I'd like to suggest as alternative to "The cli needs to know how the project is configured": I think it would be quite possible and useful for a subset of the CLI functionality to work on "non-CLI" project. I was recently working on such a project, and wanted to scaffold a few components. CLI could have done 90% of it for me, if CLI was willing to run on non-CLI projects. It would need to skip a few bits here and there and assume some defaults, but still more useful than refusing to run. Obviously not a priority for today... but maybe eventually?

@kylecordes I'd prefer to not mix up the two things in this issue tbh, since the crux of the issue here is a bad error catcher that leaves the repo in the wrong branch and not the project restrictions. Happy to have another issue open for discussion though.

@filipesilva I made #1464 a feature request for the idea above.

Just a thought, how about serving directly from dist by using this: https://github.com/blog/2228-simpler-github-pages-publishing ?

@intellix I was thinking about that really... it would make the process a LOT simpler. Have you checked if it also works with user/organization pages? If so, I'm definitely partial to changing it that way.

The whole thing could be rewritten with a ng build --output-path=docs --base-url=projectName this way.

afraid I've never used it before, but they just posted a new blog post about it becoming even easier if it's relevant :) https://github.com/blog/2289-publishing-with-github-pages-now-as-easy-as-1-2-3

After giving ng-serve

This message emerged
You have to be inside an ember-cli project to use the serve command.

I have to install ember-cli?

@samverneck no, it's just a message from ember-cli (it's the base for angular-cli). We should change it tbh.

Anyone resolved this?
I got the error after duplicating an ng project.

just got this issue tonight. first it complained that it couldn't delete src because files were in use or something.

I was still 'serving' so i thought that was the culprit. I shut it down and tried to run again, then got the 'you must be inside an Angular-CLI project' error.

Running the latest everything.

@randyaa -- I encountered the same problem today after doing a global cleanup of my node packages.

After digging into the angular-cli code, it looks like it's checking for the presence of the @angular/cli module as a dependency in your package.json. The problem of course being that, up until recently, this module was named angular-cli. So update your package.json to use the new module name/version and you should be good.

I think it'd be nice if this got fixed though, since I imagine a lot of projects are still using the old package name and the error is not super clear. I'll submit a PR if I get time.

I am also getting the same issue. As @ibwhite said that it should be @angular/cli in package.json so I have the same entry though I am getting the same error.

I had "angular-cli": "1.0.0-beta.24" in my package.json and I updated it with a package.json overwrite, that changed it to "@angular/cli": "1.0.0-beta.30", which gave me this error. I changed it back to "angular-cli": "1.0.0-beta.24" and it is working again. I ended up here because of the unclear message as well.

Is it right way to do. As angular cli has changed its dependencies.

On Thu 9 Feb, 2017, 8:51 AM Ryan Dammrose, notifications@github.com wrote:

I had "angular-cli": "1.0.0-beta.24" in my package.json and I updated it
with a package.json overwrite, that changed it to "@angular/cli":
"1.0.0-beta.30", which gave me this error. I changed it back to "angular-cli":
"1.0.0-beta.30" and it is working again.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/1400#issuecomment-278536161,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJuOhnwFQJKiPSfF6oN2jbxN3ys2EJVCks5raoY-gaJpZM4JRPQ4
.

@maplion I tried that but it's asking me to select versions below 1.0.0-beta.28.3. It says could not find specified dependency.

@abhinaypandey I ran an npm install -g @angular/cli and an npm install @angular/cli and it seems to be bundling/compiling again as intended with the new format "@angular/cli": "1.0.0-beta.30".

Note: I did have to rename / delete my node_modules folder and redo an npm install in order to clean up some other errors I was getting after the change.

I just run into this problem,
Fixed updating angular-cli in this way:

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest

No need to delete the node_modules folder

I have tried @plastikaweb 's instructions, but not successed

mmm @dinhkk have you tried to run ng init after that?

@plastikaweb solution worked for me after changing my package.json, angular-cli.json and running ng init after that.

Hi ,
Try the below solution may be it could help.
Step 1. Run this command on root folder [npm install -g angular -cli]
Step 2. Create new folder for your project [ng new project_folder_name]
Step 3. Enter inside that folder [cd project_folder_name]
Step 4. Run the project by this command [ng serve]
(Note: Now on localhost:4200, the demo project will run)
Step 5. Copy the '/src' folder of your existing project and replace with the '/src' of your newly created project from Project's root folder only.

Do let me know if you have any confusion.

@nbora98 hey ,Your last sentence blind my dog's eyes

@seize11 你亮瞎了我的狗眼

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajjejosefsson picture rajjejosefsson  Â·  3Comments

brtnshrdr picture brtnshrdr  Â·  3Comments

ericel picture ericel  Â·  3Comments

gotschmarcel picture gotschmarcel  Â·  3Comments

MateenKadwaikar picture MateenKadwaikar  Â·  3Comments