ForInStatement 的左侧属性期望节点的类型为 ["VariableDeclaration","LVal"] 但未定义 使用 --force 继续

Joh*_*333 3 angularjs gruntjs bower babeljs

我有一个大问题。我们使用 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.
Run Code Online (Sandbox Code Playgroud)

当我们构建我们的应用程序时。

我在google上搜索了这个问题,发现它与babel的版本有一定关系。但我不明白它以前是如何工作的,现在又不起作用了。

我检查过,我 100% 确定我们没有更改任何依赖项,不仅是 babel,还有其他依赖项。

在出现问题的文件中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"
    }

}
Run Code Online (Sandbox Code Playgroud)

我们还使用 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'
                    ]
                }]
            }
        },
Run Code Online (Sandbox Code Playgroud)

小智 10

检查具有“var”变量初始化的“for”循环上的代码,并将其替换为“let”。就我而言,它解决了问题。