TypeError: Cannot read property 'substr' undefined - source- node.js

This error occurs as a result of resolving this issue.

Here is my 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 

(I also use npm v4.1.1 )

When I try to build @ionic/app-scripts I get the following error:

 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) 

If necessary, when I run npm run build (to build @ionic/app-scripts ), this is the build log:

 [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** 

EDIT:

I added the configuration:

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

... to packages.json , which seemed to fix the error, but now I came across another:

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

What throws when I try to do ionic serve (assembly @ionic/app-scripts now works fine)

EDIT # 2:

Does ionic on the source map? Because an error occurs because they are not built

+6
source share
3 answers

This error occurs due to the presence of two two classes / components in one ts file.

A brutal way to fix it.

Go to node_modules \ webpack-sources \ node_modules \ source-map \ lib \ source-map \ source- node.js

And exchanging all 2 times:

 var nextLine = remainingLines[0]; 

For this

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

The problem with this solution is that you cannot put it in version control, as this is node modules

+8
source

I added the configuration:

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

... to packages.json, which apparently fixed the error.

In the editor above, I described another error that I am facing

+2
source

As I resolve this issue, the package.json option is added:

 "config": { "ionic_source_map_type": "eval" } 
+2
source

Source: https://habr.com/ru/post/1014509/


All Articles