Angular-cli: Path must be a string. Received undefined.

Created on 12 Sep 2016  路  4Comments  路  Source: angular/angular-cli

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    --> Debian 8.0 Jessie 64-bit
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    --> Node 6.5.0
    --> angular-cli: 1.0.0-beta.11-webpack.8 node: 6.3.1 os: linux x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
  4. The log given by the failure. Normally this include a stack trace and some
    more information. Path must be a string. Received undefined TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.resolve (path.js:1148:7) at Object.getWebpackCommonConfig (/home/ferdinand/dev/project/client/node_modules/angular-cli/addon/ng2/models/webpack-build-common.ts:140:35) at new NgCliWebpackConfig (/home/ferdinand/dev/project/client/node_modules/angular-cli/addon/ng2/models/webpack-config.ts:13:30) at Class.exports.default.Task.extend.run (/home/ferdinand/dev/project/client/node_modules/angular-cli/addon/ng2/tasks/serve-webpack.ts:19:22) at /home/ferdinand/dev/project/client/node_modules/angular-cli/addon/ng2/commands/serve.ts:84:26 at process._tickCallback (internal/process/next_tick.js:103:7)
  5. Mention any other details that might be useful.

This happens with serve as well as with build, regardless of whether an environment argument (e.g. --dev) is passed or not.

Debugged webpack-build-common.ts at the mentioned position and everything seems to be fine there, meaning that both appRoot and appConfig.environments['source'] (or appConfig.environments['dev'] ) when running ng serve --dev are a string containing a path.


Thanks! We'll be in touch soon.

Most helpful comment

I ran into this issue as well and it was because angular-cli.json was out of date. I updated it based on what ng new would generate for a new project and now things work.

All 4 comments

I was receiving this same error after upgrading from RC5 to RC6 on:
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: win32 x64

I added three lines to my angluar-cli.json that seemed to fix the issue.

      "scripts": [],
      "styles": [],
      "assets": "assets",

I looked through webpack-build-common.ts and it looks like scripts and styles should have defaulted to [] if they were undefined but they weren't for some reason. I am not sure if that is a bug or an issue with something that I was doing. Assets didn't seem to have any default value if it was not defined so that explains the "Received undefined TypeError".

I still have to debug other errors that I believe are unrelated before I can confirm this fixes the issue.

I ran into this issue as well and it was because angular-cli.json was out of date. I updated it based on what ng new would generate for a new project and now things work.

@fmccready adding the "assets" property solved it for me. Thank you. Unfortunately there's no documentation on that.

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

rwillmer picture rwillmer  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

jbeckton picture jbeckton  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments