Angular-cli: The option --proxy-config is not registered with the serve command.

Created on 1 Nov 2016  路  8Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.11-webpack.2
node: 6.9.1
os: win32 x64

Repro steps.

I added "start": "ng serve --proxy-config proxy.conf.json" to the package.json. I created the proxy.conf.json file in the same directory as the package.json with the following code in it:
{
"/api": {
"target": "http://localhost:1111",
"secure": false
}
}

I then ran npm start from my app directory.

The log given by the failure.

npm start
ng serve --proxy-config proxy.conf.json

The option '--proxy-config' is not registered with the serve command. Run ng serve --help for a list of supported options.

Mention any other details that might be useful.

ng serve --help only has --proxy listed in it.


Thanks! We'll be in touch soon.

Most helpful comment

I had the same error. I think the correct syntax is:

ng serve --proxy-config=proxy.conf.json

All 8 comments

@Cassidie you are using an outdated version of the cli. Update to the latest version and see if the issues persist.

@Cassidie Just to elaborate more on what @deebloo said,

You'll want to update your package.json to use the latest version of the angular cli (currently "angular-cli": "1.0.0-beta.19-3")

You will also want to reinstall the angular cli globally

  1. npm remove -g angular cli to remove it
  2. npm cache clean to clear any cached information related to the cli
  3. npm install -g angular-cli to reinstall it globally.

Then you'll want to make sure to delete your node_modules directory in your project because there are a few dependencies in there that can get left behind if you just delete the angular-cli module.

Then you'll need to do npm install in your project root to make sure that you have the latest version of the angular-cli installed (as well as all your other dependencies)

There may be some other files that need to be update in the process because angular-cli beta 11 was before the time of NgModules so you'll likely need to upgrade your entire project if you want to have the most effective development environment, this is outside the scope of the CLI however.

Thank you for the responses! I have updated the cli and my project, but I now have an ng build error:

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.getWebpackCommonConfig (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\angular-cli\models\webpack-build-common.js:23:26)
    at new NgCliWebpackConfig (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\angular-cli\models\webpack-config.js:15:29)
    at Class.run (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\angular-cli\tasks\build-webpack.js:17:22)
    at Class.run (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\angular-cli\commands\build.js:50:26)
    at Class.<anonymous> (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\angular-cli\lib\models\command.js:152:17)
    at tryCatch (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\rsvp\dist\lib\rsvp\-internal.js:215:12)
    at invokeCallback (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\rsvp\dist\lib\rsvp\-internal.js:230:13)
    at C:\Builds\Github\vintage-software\sprint-app\App\node_modules\rsvp\dist\lib\rsvp\then.js:29:16
    at flush (C:\Builds\Github\vintage-software\sprint-app\App\node_modules\rsvp\dist\lib\rsvp\asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I appreciate your help!

It looks like it can't read the "webpack common config" you're likely missing some files, here's a screenshot of what my root looks like.

image

You may have to generate a new project with the updated cli, and move your src over to it, and then update the package.json to include any packages you installed on your previous project.

My directories match yours. I think you might be right about generating a new project and migrating mine to it. I read in the angular-cli update docs that it recommends to update with a migration, but I thought I could be slick and do it without that. Live and learn! haha I will try that! Thank you again!

I was able to get the proxy working by regenerating my project!

I had the same error. I think the correct syntax is:

ng serve --proxy-config=proxy.conf.json

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

IngvarKofoed picture IngvarKofoed  路  3Comments

ericel picture ericel  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

sysmat picture sysmat  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments