TypeError:无法读取undefined - source-node.js的属性'substr' [英] TypeError: Cannot read property 'substr' of undefined - source-node.js

查看:901
本文介绍了TypeError:无法读取undefined - source-node.js的属性'substr'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此错误是因为解决了此问题 <这是我的离子信息

  Cordova CLI:6.5.0 
Ionic Framework版本:2.0.0
Ionic CLI版本:2.2.1
Ionic App Lib版本:2.2.0
Ionic App Scripts版本:1.0.0
ios-deploy版本:未安装
ios-sim版本:未安装
操作系统:Windows 10
节点版本:v7.4.0
Xcode版本:未安装

(我也在使用npm v4.1.1



尝试构建 @ ionic / app-scripts ,我收到以下错误:

  E:\Documents\Year_3 \ Mobile_Application_Development \ mammoth-v2 \\\
ode_modules\webpack-sources \\\
ode_modules\source-map \lib \ sources-node.js:95
var code = nextLine.substr(0,mappin g.generatedColumn -
^

TypeError:无法在函数中读取未定义
的属性'substr'。< anonymous> (E:\Documents\Year_3 \Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \\\
ode_modules\source-map \lib \ sources-node.js:95:30)$ b在BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping]的Array.forEach(native)
$ b(E:\Documents\Year_3 \Mobile_Application_Development\mammoth-v2 \ node_modules \webpack-sources \\\
ode_modules \\ \\ source-map \lib \ source-map-consumer.js:155:14)
at Function.SourceNode_fromStringWithSourceMap [from fromStringWithSourceMap](E:\Documents\Year_3 \Mobile_Application_Development\mammoth-v2 \ nnode_modules \webpack-sources \\\
ode_modules\source-map \lib \ source-node.js:80:24)
在SourceMapSource.node(E:\Documents \Year_3 \ Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \lib \ SourceMapSource.js:42:20)Replac的
eSource.node(E:\Documents\Year_3 \Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \lib \ReplaceSource.js:69:29)
at CachedSource.node( E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \lib \CachedSource.js:12:23)
at E:\Documents\Year_3 \ Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \lib \ConcatSource.js:40:49
at Array.map(native)
at ConcatSource.node(E: \Documents\Year_3\Mobile_Application_Development\mammoth-v2 \\\
ode_modules\webpack-sources \lib \ ConcecatSource.js:39:60)

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

  [07: 28:45] ionic-app-scripts 1.0.0 
[07:28:45] build dev开始...
[07:28:45]干净的开始...
[07:28:45]干净完成4毫秒
[07:28:45]复制开始。 ..
[07:28:45]开始转换...
[07:28:49] transile在4.44 s完成
[07:28:49] webpack开始......
[07:28:49]复制完成4.57 s

**这里出现错误**

编辑:



我添加了配置:

 config:{
ionic_generate_source_map:false
},

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


错误:ENOENT:没有这样的文件或目录,打开'main.js.map'


当我尝试做 ionic serve 时引发的构建 @ ionic / app-scripts 现在工作正常)



编辑# 2:



ionic 是否依赖源地图来运​​行?由于错误的产生,因为非构建

解决方案

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



解决此问题的一种野蛮方式。



将转至node_modules \webpack-sources \\\
ode_modules \ source-map \lib \ source-map \ source-node.js



并且交换所有2次出现:

  var nextLine = remainingLines [0]; 

到此

  var nextLine = remainingLines [0] || ; 

此解决方案的问题在于您无法将其置于版本控制中,因为这是节点模块


This error comes as a result of resolving this question

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 am also using npm v4.1.1)

When attempting to build @ionic/app-scripts, I am getting 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 needed, 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 am now faced with another one:

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

Which is thrown when I attempt to do ionic serve (the build of @ionic/app-scripts works just fine now)

EDIT #2:

Does ionic rely on a source map to run? As the error is arising because non are built

解决方案

This error comes from having two 2 classes/components in one ts file.

A brutal way to fix this.

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

And exchanging all 2 times this appears:

var nextLine = remainingLines[0];

To this

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

Problem with this solution is that you can't put it into version control since this is node modules

这篇关于TypeError:无法读取undefined - source-node.js的属性'substr'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆