TypeError:无法读取未定义的属性'substr' – source-node.js

这个错误是由于解决了这个问题

这是我的ionic info

 Cordova CLI: 6.5.0 Ionic Framework Version: 2.0.0 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.0.0 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 10 Node Version: v7.4.0 Xcode version: Not installed 

(我也使用npm v4.1.1

试图构build@ionic/app-scripts时,出现以下错误:

 E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:95 var code = nextLine.substr(0, mapping.generatedColumn - ^ TypeError: Cannot read property 'substr' of undefined at Function.<anonymous> (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:95:30) at Array.forEach (native) at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\node_modules\source-map\lib\source-map-consumer.js:155:14) at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:80:24) at SourceMapSource.node (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\lib\SourceMapSource.js:42:20) at ReplaceSource.node (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\lib\ReplaceSource.js:69:29) at CachedSource.node (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\lib\CachedSource.js:12:23) at E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\lib\ConcatSource.js:40:49 at Array.map (native) at ConcatSource.node (E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2\node_modules\webpack-sources\lib\ConcatSource.js:39:60) 

如果需要,当我运行npm run build (构build@ionic/app-scripts )时 ,这是构build日志:

 [07:28:45] ionic-app-scripts 1.0.0 [07:28:45] build dev started ... [07:28:45] clean started ... [07:28:45] clean finished in 4 ms [07:28:45] copy started ... [07:28:45] transpile started ... [07:28:49] transpile finished in 4.44 s [07:28:49] webpack started ... [07:28:49] copy finished in 4.57 s **errors arise here** 

编辑:

我添加了configuration:

 "config": { "ionic_generate_source_map": false }, 

packages.json似乎解决了错误,但现在面临着另一个:

Error: ENOENT: no such file or directory, open 'main.js.map'

当我尝试做ionic serve时候会抛出这个问题( @ionic/app-scripts的构build现在工作的很好)

编辑#2:

ionic是否依靠源图运行? 由于错误是由于非build立的

       

网上收集的解决方案 "TypeError:无法读取未定义的属性'substr' – source-node.js"

这个错误来自一个ts文件中有两个2类/组件。

一个残酷的方法来解决这个问题。

去node_modules \ webpack-sources \ node_modules \ source-map \ lib \ source-map \ source-node.js

所有这2次交换出现:

 var nextLine = remainingLines[0]; 

对此

 var nextLine = remainingLines[0] || ''; 

这个解决scheme的问题是你不能把它放到版本控制中,因为这是节点模块

我添加了configuration:

 "config": { "ionic_generate_source_map": false }, 

package.json似乎修复了错误。

在上面的编辑中 ,我现在描述了我遇到的另一个错误

我解决这个问题的方式,是添加到package.json这个configuration选项:

 "config": { "ionic_source_map_type": "eval" }