angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

patterns.map is not a function

Open ghost opened this issue 9 years ago • 13 comments

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 avatar Dec 15 '16 00:12 ghost

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 avatar Dec 16 '16 07:12 ghost

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

ghost avatar Dec 16 '16 07:12 ghost

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.

ghost avatar Dec 16 '16 07:12 ghost

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.

dev-johnny-gh avatar Dec 16 '16 15:12 dev-johnny-gh

The feature request: https://github.com/angular/angular-cli/issues/2405

ghost avatar Dec 19 '16 00:12 ghost

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

filipesilva avatar Dec 30 '16 15:12 filipesilva

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.

loicsalou avatar Jan 05 '17 06:01 loicsalou

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?

redaikidoka avatar Jan 22 '17 17:01 redaikidoka

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.

agatsoh avatar Feb 08 '17 11:02 agatsoh

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

glorment avatar Feb 22 '17 12:02 glorment

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"],

redaikidoka avatar Feb 22 '17 15:02 redaikidoka

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 avatar Mar 16 '17 19:03 hansl

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.