TypeError: Cannot read property 'substr' of undefined
While everything worked during development now suddenly cloning a fresh repo fails with TypeError: Cannot read property 'substr' of undefined
OS?
Windows 10 as well as Ubuntu 14.04
Versions.
ng --version angular-cli: 1.0.0-beta.26 node: 7.4.0 os: win32 x64 @angular/common: 2.4.5 @angular/compiler: 2.4.5 @angular/core: 2.4.5 @angular/forms: 2.4.5 @angular/http: 2.4.5 @angular/platform-browser: 2.4.5 @angular/platform-browser-dynamic: 2.4.5 @angular/router: 3.4.5 @angular/compiler-cli: 2.4.5
node -v v7.4.0
Repro steps.
git clone https://github.com/KIC/angular2-material-seed.git
cd angular2-material-seed
npm install
ng serve
The log given by the failure.
C:\sources\kic\angular2-material-seed>ng serve
** NG Live Development Server is running on http://localhost:4200. **
92% chunk asset optimizationC:\Users\kindler\sources\kic\angular2-material-seed\node_modules\source-map\lib\source-node.js:115
node.add(nextLine.substr(0, mapping.generatedColumn));
^
TypeError: Cannot read property 'substr' of undefined
at Function.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\source-map\lib\source-node.js:115:26)
at Array.forEach (native)
at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\source-map\lib\source-map-consumer.js:155:14)
at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\source-map\lib\source-node.js:80:24)
at SourceMapSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\SourceMapSource.js:42:20)
at ReplaceSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ReplaceSource.js:69:29)
at CachedSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\CachedSource.js:12:23)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:39:60)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:39:60)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:39:60)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\ConcatSource.js:39:60)
at ConcatSource.proto.sourceAndMap (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\SourceAndMapMixin.js:28:18)
at CachedSource.sourceAndMap (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack-sources\lib\CachedSource.js:51:28)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\SourceMapDevToolPlugin.js:57:32)
at Array.map (native)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\SourceMapDevToolPlugin.js:43:84)
at Array.forEach (native)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\SourceMapDevToolPlugin.js:42:11)
at Compilation.applyPlugins1 (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:75:14)
at self.applyPluginsAsync.err (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:605:11)
at next (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:138:11)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\ProgressPlugin.js:118:5)
at Compilation.applyPluginsAsyncSeries (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:142:13)
at self.applyPluginsAsync.err (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:601:10)
at next (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:138:11)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\ProgressPlugin.js:114:5)
at next (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\extract-text-webpack-plugin\index.js:321:4)
at Compilation.applyPluginsAsyncSeries (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:142:13)
at sealPart2 (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:597:9)
at next (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:138:11)
at Compilation.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\ProgressPlugin.js:110:5)
at next (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\extract-text-webpack-plugin\index.js:297:5)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:356:16
at iteratorCallback (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:936:13)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:840:16
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\extract-text-webpack-plugin\index.js:281:6
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:356:16
at eachOfArrayLike (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:929:9)
at eachOf (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:991:5)
at Object.eachLimit (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:3089:3)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\extract-text-webpack-plugin\index.js:252:11
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:3025:16
at eachOfArrayLike (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:941:9)
at eachOf (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:991:5)
at Object.eachLimit (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\async\dist\async.js:3089:3)
at ExtractTextPlugin.<anonymous> (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\extract-text-webpack-plugin\index.js:249:10)
at Compilation.applyPluginsAsyncSeries (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:142:13)
at Compilation.seal (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:545:8)
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compiler.js:474:16
at C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\tapable\lib\Tapable.js:225:11
at _addModuleChain (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:452:11)
at processModuleDependencies.err (C:\Users\kindler\sources\kic\angular2-material-seed\node_modules\webpack\lib\Compilation.js:423:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Cloned the repo, installed the npm modules.
Ran ng build to make sure it builds, which it does.
ng serve succeeds and serves up a page, see screen shot attached.

Can you please perform a ng build and confirm it is successful ?
Hello. Also, you might want to try to reinstall or update Angular CLI? To update angular-cli to a new version, you must update both the global package and your project's local package, if any:
Global package:
npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@latest
Local project package:
rm -rf node_modules dist # use rmdir on Windows npm install --save-dev angular-cli@latest npm install ng init
Let us know ... Cheers!
following your steps leads me to the same issue

On my ubuntu 14.04 I have the same issue. However if I use a fresh docker container it just works. Seems like the tooling is a bit shaky ...
I have now wrapped everything in a gradle task. If you freshly clone the repo again and then execute gradlew ngServe then it works fine on ubuntu. But it still has the same error as above on windows (10).
Just tested in windows 10, using both gitbash and cmd and could not repro. I'm sorry, but it seems like something specific to your system.
I think I have found the issue! You are not allowed to use windows symlinks (mklink) anywhere in the path also not on some parent folders of the repo.
@KIC I had a junction in my "projects" directory - above the root of the project. The same problem. The same workarund (running outside any symlinks/junctions) caused that it works.
I can also confirm angular-cli has issues with symlinks, in my case on Linux.
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.