Skip to content

patterns.map is not a function #3566

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
ghost opened this issue Dec 15, 2016 · 13 comments
Closed

patterns.map is not a function #3566

ghost opened this issue Dec 15, 2016 · 13 comments
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix

Comments

@ghost
Copy link

ghost commented Dec 15, 2016

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

$ ng --version
angular-cli: local (v1.0.0-beta.22-1, branch: master)
node: 6.9.2
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

This app is working fine on 1.0.0-beta.21. On the latest master branch I get this error.

The log given by the failure.

Normally this include a stack trace and some more information.

$ ng serve
patterns.map is not a function
TypeError: patterns.map is not a function
    at GlobCopyWebpackPlugin.apply (C:\projects\git\angular-cli\packages\angular-cli\plugins\glob-copy-webpack-plugin.ts:16:29)
    at Compiler.apply (C:\projects\git\angular-cli\node_modules\tapable\lib\Tapable.js:270:16)
    at WebpackOptionsApply.process (C:\projects\git\angular-cli\node_modules\webpack\lib\WebpackOptionsApply.js:59:18)
    at webpack (C:\projects\git\angular-cli\node_modules\webpack\lib\webpack.js:28:48)
    at Class.run (C:\projects\git\angular-cli\packages\angular-cli\tasks\serve-webpack.ts:38:27)
    at C:\projects\git\angular-cli\packages\angular-cli\commands\serve.ts:105:26
    at process._tickCallback (internal/process/next_tick.js:103:7)
@ghost
Copy link
Author

ghost commented Dec 16, 2016

Tried on latest version, still an issue. Hope someone can shed a light on this! I really want to use the new i18n feature, our entire release depends on that feature... @hansl

@ghost
Copy link
Author

ghost commented Dec 16, 2016

I've done some research, in my case the patterns variable is a string, not an array...

@ghost
Copy link
Author

ghost commented Dec 16, 2016

I've "fixed" it by adding a check here:

 if (patterns instanceof Array) {
      patterns = patterns.map(pattern => fs.statSync(path.resolve(context, pattern)).isDirectory()
        ? pattern += '/**/*'
        : pattern
      );
    }

However, I have no idea if this is intended behavior, and why this is now happening.

In my case, "patterns" equals "img".
Hope this helps.

@dev-johnny-gh
Copy link

dev-johnny-gh commented Dec 16, 2016

I have same issue. Finally, It looks like caused by a scheme changing.

image

The item "assets" now is an array.

image

I set the value from "assets": "assets" to "assets": ["assets"] in angular-cli.json, and the error was gone.

@ghost
Copy link
Author

ghost commented Dec 19, 2016

The feature request: #2405

@filipesilva
Copy link
Contributor

This seems to be a problem with how we get defaults, which broke with #2405.

@filipesilva filipesilva self-assigned this Dec 30, 2016
@filipesilva filipesilva added command: build P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix labels Dec 30, 2016
@loicsalou
Copy link

although issue has been closed... I had same exception when moving from beta.22-1 to beta.24; I changed "assets" parameter in angular-cli.json.

  • not working: "assets: "assets"
  • working: "assets: [ "assets" ]

This parameter must be an array.

@redaikidoka
Copy link

I have this problem as well, but on my platform, the angular-cli package.json has more details in it, and changing to "assets": ["assets"] causes an error.

Is there any more information I can provide or anything else I can do to support this?

@agatsoh
Copy link

agatsoh commented Feb 8, 2017

Yup still have the same problem. I migrated from 1.0.0 beta 17 to 1.0.0 beta 30 and loicsalou solution worked for me.
"assets: [ "assets" ] solves the problem.

@glorment
Copy link

still have same error on "angular-cli": "1.0.0-beta.28.3",

@redaikidoka
Copy link

So it's not totally obvious from above, @glorment , but if you go into your
angular-cli.json
for your project, find the "apps" section, change "assets": "assets", to "assets": ["assets"], that fixed the problem for a bunch of folks!

So your **angular-cli.json ** will start something like:

{
  "project": {
    "version": "1.0.0-beta.32.3",
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": ["assets"],

@hansl
Copy link
Contributor

hansl commented Mar 16, 2017

This has been marked as a breaking change and is working as intended. People following updates of hte CLI shouldn't have any problems, and new projects are generated correctly.

@hansl hansl closed this as completed Mar 16, 2017
@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
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

No branches or pull requests

7 participants