Skip to content

Upgrade Angular-cli@webpack and ng build fail #1953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mavericks065 opened this issue Sep 2, 2016 · 15 comments
Closed

Upgrade Angular-cli@webpack and ng build fail #1953

mavericks065 opened this issue Sep 2, 2016 · 15 comments

Comments

@mavericks065
Copy link

mavericks065 commented Sep 2, 2016

  1. OS El Capitan
  2. angular-cli: 1.0.0-beta.11-webpack.8
    node: 5.6.0
    os: darwin x64
  3. My app was created using angular-cli then moved to angular-cli: 1.0.0-beta.11-webpack.2
    I tried to upgrade angular-cli@webpack so I uninstalled it, cleaned and re-installed.
    When I ran ng build I got the following stack trace:

ng build
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
The "defaults.prefix" and "defaults.sourceDir" properties of angular-cli.json are deprecated in favor of "apps[0].root" and "apps[0].prefix". Please update in order to avoid errors in future versions of angular-cli.
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at Object.getWebpackCommonConfig (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/angular-cli/addon/ng2/models/webpack-build-common.ts:23:25)
at new NgCliWebpackConfig (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/angular-cli/addon/ng2/models/webpack-config.ts:13:30)
at Class.exports.default.Task.extend.run (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/angular-cli/addon/ng2/tasks/build-webpack.ts:16:22)
at Class.Command.extend.run (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/angular-cli/addon/ng2/commands/build.ts:49:26)
at Class. (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/angular-cli/lib/models/command.js:152:17)
at lib$rsvp$$internal$$tryCatch (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/rsvp/dist/rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/rsvp/dist/rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/rsvp/dist/rsvp.js:1019:11)
at lib$rsvp$asap$$flush (/Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/rsvp/dist/rsvp.js:1198:9)
at nextTickCallbackWith0Args (node.js:453:9)
at process._tickCallback (node.js:382:13)

Here is my angular-cli.json: (the version of my project is 1.0.0-beta.11-webpack.2 but I don't understand since I followed the procedure I read here )

{
"project": {
"version": "1.0.0-beta.11-webpack.2",
"name": "***************"
},
"apps": [
{
"main": "src/main.ts",
"tsconfig": "src/tsconfig.json",
"mobile": false
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "config/protractor.conf.js"
}
},
"test": {
"karma": {
"config": "config/karma.conf.js"
}
},
"defaults": {
"prefix": "app",
"sourceDir": "src",
"styleExt": "scss",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
}
}

Thank you for your help.

@ghost
Copy link

ghost commented Sep 2, 2016

The error message is clear. defaults.prefix and defaults.sourceDir were removed and moved to app. Make ng init and view the diff. By the way, the guide is not as good as it should be, it is missing some important facts like that public was removed in favor of src/assets, and so on...

@mavericks065
Copy link
Author

mavericks065 commented Sep 2, 2016

@christiandreher I did it but I got in angular-cli.json exactly the same:

{
  "project": {
    "version": "1.0.0-beta.11-webpack.2",
    "name": "poiuytreza"
  },
  "apps": [
    {
      "main": "src/main.ts",
      "tsconfig": "src/tsconfig.json",
      "mobile": false
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "config/protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "config/karma.conf.js"
    }
  },
  "defaults": {
    "prefix": "app",
    "sourceDir": "src",
    "styleExt": "css",
    "prefixInterfaces": false,
    "lazyRoutePrefix": "+"
  }
}

By the way I don't understand why it is describing the version at 1.0.0-beta.11-webpack.2.

@ghost
Copy link

ghost commented Sep 2, 2016

What is the output if you run the following commands from your project root?

  1. npm ls --depth 0 | grep angular-cli
  2. npm ls -g --depth 0 | grep angular-cli

It seems like you haven't updated angular-cli globally, but I can't tell for sure. If the second command returns @1.0.0-beta.11-webpack.2 then you need to update this aswell with the following commands:

$ npm uninstall -g angular-cli
$ npm cache clean
$ npm install -g angular-cli@webpack

And did you read this notice?

IMPORTANT NOTE: Currently project generated with ng new will use a wrong local CLI version (see #1528). After initializing your project, run npm install --save-dev angular-cli@webpack to set the correct version.

(Source)

@mavericks065
Copy link
Author

@christiandreher

1-

npm ls --depth 0 | grep angular-cli
├── [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
...

2-

npm ls -g --depth 0 | grep angular-cli
├── [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: [email protected] || 2.x.x, required by [email protected]

Yes I read this notice. however i did not run it on the new project, so I re-created a new project and ran it and it did not change anything: same angular-cli.json

@kethan
Copy link

kethan commented Sep 2, 2016

me too getting the same error for

npm ls -g --depth 0 | grep angular-cli

+-- [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: [email protected] || 2.x.x, required by [email protected]
npm ERR! peer dep missing: @angular/platform-server@^2.0.0-rc.5, required by @angular/[email protected]
npm ERR! peer dep missing: zone.js@^0.6.17, required by @angular/[email protected]
npm ERR! peer dep missing: tslint@^3.0.0, required by [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.8.0 || ^1.9.0-dev, required by [email protected]
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/async-some
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/lodash._baseuniq/node_modules/lodash._setcache
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/lodash.without/node_modules/lodash._basedifference/node_modules/lodash._setcache
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/lodash.repeat
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/which/node_modules/is-absolute

@ghost
Copy link

ghost commented Sep 2, 2016

@mavericks065 thats strange. I would say that there is an old binary somewhere, but I can't tell better. I think that you'll have to wait for an official angular-cli member to help you. What you could try until that, is to completely remove all node_modules folders and npm cache clean and completely reinstall everything.

@kethan for what I can tell, this is completely unrelated.

@bingneef
Copy link

bingneef commented Sep 2, 2016

@mavericks065 I have had the same issue (the length of undefined), but I believe it was fixed by adding environments to your angular-cli.json (especially the source index). Hopefully this would work for you too.

{
"project": {
"version": "1.0.0-beta.11-webpack.8",
"name": "application_name"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [],
"scripts": [],
"environments": {
"source": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"dev": "environments/environment.dev.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "sass",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
}
}

@mavericks065
Copy link
Author

@bingneef thanks. I think we made some progress.

However when it is building I get errors like: (I don't copy paste all of them because there are too many of them just the firsts). I thought I could solve them with this issue #1901 but did not work.

ERROR in [default]
Cannot find global type 'Array'.

ERROR in [default]
Cannot find global type 'Boolean'.

ERROR in [default]
Cannot find global type 'Function'.

ERROR in [default]
Cannot find global type 'IArguments'.

ERROR in [default]
Cannot find global type 'Number'.

ERROR in [default]
Cannot find global type 'Object'.

ERROR in [default]
Cannot find global type 'RegExp'.

ERROR in [default]
Cannot find global type 'String'.

ERROR in [default] /Users/mba/Business/workspace/angular-ionic/iSecretVault_webapp_ng2/node_modules/@angular/common/src/directives/ng_class.d.ts:81:33
Cannot find name 'Set'.

@ghost
Copy link

ghost commented Sep 2, 2016

Are you sure that npm ls --depth 0 | grep typescript returns 2.0.0 as version for typescript? Maybe you have installed it globally?

@iceinsidefire
Copy link

iceinsidefire commented Sep 2, 2016

I am facing same problem as @mavericks065.
node : v6.5.0
npm : 3.10.0
angular-cli: 1.0.0-beta.11-webpack.8

npm ls --depth 0 | grep typescript
├── [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: [email protected] || 2.x.x, required by [email protected]
npm ERR! peer dep missing: typescript@^1.9.0-dev, required by @angular/[email protected]
npm ERR! peer dep missing: typescript@^1.8.0 || ^1.9.0-dev, required by [email protected]

@ghost
Copy link

ghost commented Sep 2, 2016

Try fixing the version of typescript to 2.0.0. In your package.json, change this line:

"typescript": "^2.0.0",

to

"typescript": "2.0.0",

then run npm install

@mavericks065
Copy link
Author

@christiandreher When I followed bingneef recommendation I got the new errors. Then I changed my typescript version to

"typescript": "2.0.0"

as it was recommended but completely forgot to run

npm install

now the build works and I get :

npm ls --depth 0 | grep typescript
├── UNMET PEER DEPENDENCY [email protected]

Thanks for your help guys.

@iceinsidefire
Copy link

It worked. But got issue as mentioned in Issue 19481.
Thanks

@thomas-mindruptive
Copy link

The problem still exists with

  • angular release (2.0.0)
  • npm 3.10.8
  • node 6.5.0
  • angular cli 1.0.0-beta.16
  • typescript 2.0.3
  • webpack 2.1.0-beta.22

It can be solved by @christiandreher (thanks!) hint to pin the typescript version to 2.0.0.
It's good to have a solution but in order to avoid future problems I'd like to understand the exact reason why those "cannot find global..." happen.

Any help is appreciated, thanks

kyhau added a commit to kyhau/aws-cognito-angular2-webui that referenced this issue Jan 7, 2017
Attempted to downgrade typescript to from 2.0.3 to 2.0.0 to fix angular/angular-cli#1953
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants