Babel.js ForInStatement左侧的属性要求节点的类型为[“VariableDeclaration”,“LVal”],但得到的是未定义的类型,使用--force继续

fykwrbwg  于 2022-12-25  发布在  Babel
关注(0)|答案(1)|浏览(1221)

我有一个大问题。我们使用angular.js应用程序和maven来构建我们的应用程序。以前,当我们用bower.json构建我们的应用程序时,一切都正常。
从昨天开始我们得到了这个错误

Warning: /builds/t2i/xecm/xecm-webapp/src/main/webapp/services/document-service.js: Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got undefined Use --force to continue. Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got undefined Use --force to continue.

当我们构建应用程序时。
我在谷歌上搜索了这个问题,发现它和巴别塔的版本有点关系,但是我不知道以前是怎么工作的,现在它不工作了。
我检查了一下,我100%确定我们没有改变任何依赖关系,不仅仅是对巴别塔,还有其他依赖关系。
在出现问题的文件document-service.js中,我们也没有做任何更改。最后一次更改是在2个月前,在这2个月内,一切正常,构建通过。
可能是什么问题?我从来没有遇到过这样奇怪的问题,我真的不知道我应该怎么做,我应该检查,以找到问题在哪里,我应该如何解决这个问题...
这是我的bower.json的样子

{
    "name": "${project.artifactId}",
    "version": "{project.version}",
    "homepage": "https://example.com/",
    "appPath": "webapp",
    "main": ["./${project.artifactId}.js"],
    "private": true,
    "dependencies": {
        "json3": "~3.2.6",
        "angular-resource": "1.6.4",
        "angular-cookies": "1.6.4",
        "angular-route": "1.6.4",
        "angular-animate": "1.6.4",
        "angular-sanitize": "1.6.4",
        "angular-touch": "1.6.4",
        "angular-gestures": "0.3.1",
        "angular-spinner": "1.0.1",
        "angular-css-injector": "1.4.0",
        "angular-truncate": "*",
        "angular-dynamic-locale": "~0.1.32",
        "angular-once": "~0.1.8",
        "angular-capitalize-filter": "~3.0.0",
        "angular-ui-router": "1.0.5",
        "xcomponent-widgets": "${project.build.directory}/${bower.components.dir}/xcomponent-widgets",
        "angular": "1.6.4",
        "ng-img-crop": "0.3.2",
        "angular-bootstrap-switch": "0.5.2",
        "angular-toastr": "2.1.1",
        "angular-moment": "1.0.1",
        "moment-timezone": "0.5.13",
        "moment": "2.15.2",  
        "ng-focus-if": "1.0.5",
        "ng-file-upload": "12.2.3",
        "ng-device-detector": "4.0.3",
        "textAngular":"1.5.16",        
        "angular-base64":"2.0.4",
        "jspdf":"1.3.2",
        "angular-clipboard":"1.5.0",
        "ngclipboard":"1.1.1",
        "angular-swx-session-storage":"1.0.2",
        "angular-cache":"4.6.0",
        "angular-highlightjs":"0.4.0",
        "angularjs-slider": "6.4.3",
        "angular-ui-select": "0.19.8",
        "angular-bootstrap":"2.5.0"
    },
    "overrides": {
        "bootstrap": {
            "main": [
                "less/bootstrap.less",
                "dist/css/bootstrap.css",
                "dist/js/bootstrap.js"
            ]
        }
    },
    "devDependencies": {
        "angular-mocks": "1.6.4",
        "angular-scenario": "1.6.4",
        "bootstrap": "~3.1.1"
    },
    "resolutions": {
        "angular": "1.6.4",
        "jquery": ">=1.9.0",
        "bootstrap": "~3.1.1",
        "moment": "2.15.2",
        "ng-file-upload": "10.1.5"
    }

}

我们还使用了grunt,这是babel配置在gruntfile-dev.js中的样子

babel: {
            options: {
                sourceMap: true,
                presets: ['@babel/preset-env'],
                sourceType: 'module'
            },
            dev: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.sources %>',
                    dest: '<%= yeoman.dev %>',
                    src: [
                        '**/*.js'
                    ]
                }]
            }
        },

我检查过了,我100%确定我们没有改变任何依赖项,不仅仅是babel,还有其他依赖项。同样在出现问题的文件document-service.js中,我们也没有做任何改变。最后一次改变是在2个月前,在这2个月里,一切正常,构建通过。问题从昨天开始。

nr9pn0ug

nr9pn0ug1#

检查“for”循环中的代码,这些循环有“var”变量初始化,并将其替换为“let”。在我的例子中,它解决了这个问题。

相关问题