angular / vscode-ng-language-service

Angular extension for Visual Studio Code
MIT License
773 stars 116 forks source link

`@angular/language-server` can't work with nodejs v12 #1664

Closed iamcco closed 2 years ago

iamcco commented 2 years ago

🐞 bug report

Is this a regression?

Work well with nodejs v14 and v16, and the view-engine also works well with nodejs v12

Description

Does not work with nodejs v12

Bug Type

What does this bug affect

Logs

nglangsvc.log

Language server output channel:

[Trace - 4:42:04 ├F10: PM┤] Sending request 'initialize - (0)'.
Params: {
    "processId": 76727,
    "rootPath": "/Users/aioiyuuko/workspaces/anduin",
    "rootUri": "file:///Users/aioiyuuko/workspaces/anduin",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "semanticTokens": {
                "refreshSupport": true
            },
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "insertReplaceSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                },
                "insertTextMode": 2
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "activeParameterSupport": true,
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "references": {
                "dynamicRegistration": true
            },
            "definition": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "honorsChangeAnnotations": false,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true
            },
            "implementation": {
                "dynamicRegistration": true
            },
            "declaration": {
                "dynamicRegistration": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "4.0.10"
            }
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///Users/aioiyuuko/workspaces/anduin",
            "name": "anduin"
        }
    ],
    "locale": "zh_CN",
    "clientInfo": {
        "name": "coc.nvim",
        "version": "0.0.80"
    }
}

[Trace - 4:42:05 ├F10: PM┤] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Angular language server process ID: 76743"
}

[Info  - 4:42:05 ├F10: PM┤] Angular language server process ID: 76743
[Trace - 4:42:07 ├F10: PM┤] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Using typescript/lib/tsserverlibrary v4.3.5 from /Users/aioiyuuko/workspaces/anduin/node_modules/typescript/lib/tsserverlibrary.js"
}

[Info  - 4:42:07 ├F10: PM┤] Using typescript/lib/tsserverlibrary v4.3.5 from /Users/aioiyuuko/workspaces/anduin/node_modules/typescript/lib/tsserverlibrary.js
[Trace - 4:42:07 ├F10: PM┤] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Using @angular/language-service v13.3.8 from /Users/aioiyuuko/.config/coc/extensions/node_modules/coc-angular/node_modules/@angular/language-service/index.js"
}

[Info  - 4:42:07 ├F10: PM┤] Using @angular/language-service v13.3.8 from /Users/aioiyuuko/.config/coc/extensions/node_modules/coc-angular/node_modules/@angular/language-service/index.js
[Trace - 4:42:09 ├F10: PM┤] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Log file: /Users/aioiyuuko/.config/coc/extensions/coc-angular-data/nglangsvc.log"
}

[Info  - 4:42:09 ├F10: PM┤] Log file: /Users/aioiyuuko/.config/coc/extensions/coc-angular-data/nglangsvc.log
[Trace - 4:42:10 ├F10: PM┤] Received response 'initialize - (0)' in 6133ms.
Result: {
    "capabilities": {
        "codeLensProvider": {
            "resolveProvider": true
        },
        "textDocumentSync": 2,
        "completionProvider": {
            "resolveProvider": true,
            "triggerCharacters": [
                "<",
                ".",
                "*",
                "[",
                "(",
                "$",
                "|"
            ]
        },
        "definitionProvider": true,
        "typeDefinitionProvider": true,
        "referencesProvider": true,
        "renameProvider": {
            "prepareProvider": true
        },
        "hoverProvider": true,
        "signatureHelpProvider": {
            "triggerCharacters": [
                "(",
                ","
            ],
            "retriggerCharacters": [
                ","
            ]
        },
        "workspace": {
            "workspaceFolders": {
                "supported": true
            }
        }
    },
    "serverOptions": {
        "logFile": "/Users/aioiyuuko/.config/coc/extensions/coc-angular-data/nglangsvc.log"
    }
}

[Trace - 4:42:10 ├F10: PM┤] Sending notification 'initialized'.
Params: {}

[Trace - 4:42:10 ├F10: PM┤] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html",
        "languageId": "html",
        "version": 1,
        "text": "\n  
\n \n
\n
\n\n\n\n\n
\n \n
\n
\n
BigONE {{ 'financial.title' | t }}
\n
\n {{ 'financial.desc' | t }}\n
\n
\n
\n \n\n \n \n
\n
\n \n {{ 'financial.summary.invest' | t }}\n \n \n {{ isHideSummary ? '' : '' }}\n \n
\n
\n \n \n {{\n summary.investment_amount | btcToFiat | async | numberFormat: 2\n }}\n \n {{ fiatCodeObservable$ | async }}\n \n ***\n
\n
\n
\n
\n {{ 'financial.summary.profit' | t }}\n
\n
\n \n \n {{\n summary.profit_amount_in_usd\n | btcToFiat: 'USDT'\n | async\n | numberFormat: 2\n }}\n \n {{ fiatCodeObservable$ | async }}\n \n ***\n
\n
\n
\n
\n {{ 'financial.summary.yesterday' | t }}\n
\n
\n \n \n {{\n summary.yesterday_profit_amount_in_usd\n | btcToFiat: 'USDT'\n | async\n | numberFormat: 2\n }}\n \n {{ fiatCodeObservable$ | async }}\n \n ***\n
\n
\n
\n \n \n \n \n \n \n
\n \n \n \n \n \n \n
\n
\n \n\n \n \n
\n \n {{ 'financial.category.all' | t }}\n
\n \n {{ tab }}\n
\n
\n \n \n \n {{ 'financial.host-only' | t }}\n \n \n \n \n \n\n \n
\n \n \n \n \n {{ 'financial.symbol.all' | t }}\n \n \n {{ s.symbol }}\n \n
3\">\n \n
\n \n
\n
\n \n {{ asset.symbol }}\n
\n
\n \n
\n \n \n \n\n
\n
\n {{ 'financial.header.asset' | t }}\n
\n
\n {{ 'financial.header.product' | t }}\n
\n
\n
\n {{ 'financial.header.peroid' | t }}\n
\n
\n {{ 'financial.header.hold' | t }}\n
\n
\n {{ 'financial.header.profit' | t }}\n
\n
\n \n\n \n\n \n \n
\n \n \n {{ product.asset.symbol }}\n \n
\n \n \n \n {{ product.name }}\n \n \n
\n \n {{ product.display_profit_rate || '--' }}\n \n \n {{ product.display_profit_rate || '--' }}\n \n
\n
\n 0\">\n {{ product.lock_period }} {{ 'financial.item.day' | t }}\n \n \n 0\">\n {{ 'financial.item.agile' | t }}\n \n \n {{ 'financial.item.anytime' | t }}\n \n \n
\n
\n 0\n )\n \"\n >\n --\n \n 0\n \"\n >\n {{ item.me_investment_valuation | numberFormat }}\n \n
\n
\n 0)\n \"\n >\n --\n \n 0\"\n >\n {{ item.me_profit_valuation | numberFormat }}\n \n
\n \n
\n \n {{ 'financial.product.state.' + product.status | t }}\n \n
\n \n {{\n !expandProduct || expandProduct!.product.id !== item.product.id\n ? ''\n : ''\n }}\n \n \n \n \n
\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" } } [Trace - 4:42:14 ├F10: PM┤] Received notification 'angular/projectLoadingStart'. Params: [ null ] [Trace - 4:42:23 ├F10: PM┤] Received notification 'angular/projectLoadingFinish'. Params: [ null ] [Trace - 4:42:23 ├F10: PM┤] Received request 'window/workDoneProgress/create - (0)'. Params: { "token": "2bf5783c-e65e-481f-8aff-e7ca60811d16" } [Trace - 4:42:23 ├F10: PM┤] Sending response 'window/workDoneProgress/create - (0)'. Processing request took 1ms No result returned. [Trace - 4:42:24 ├F10: PM┤] Received notification '$/progress'. Params: { "token": "2bf5783c-e65e-481f-8aff-e7ca60811d16", "value": { "kind": "begin", "title": "Angular", "message": "Running ngcc for /Users/aioiyuuko/workspaces/anduin/tsconfig.json" } } [Trace - 4:42:26 ├F10: PM┤] Received notification '$/progress'. Params: { "token": "2bf5783c-e65e-481f-8aff-e7ca60811d16", "value": { "kind": "end" } } [Trace - 4:42:26 ├F10: PM┤] Received notification 'window/logMessage'. Params: { "type": 3, "message": "Enabling Ivy language service for /Users/aioiyuuko/workspaces/anduin/tsconfig.json." } [Info - 4:42:26 ├F10: PM┤] Enabling Ivy language service for /Users/aioiyuuko/workspaces/anduin/tsconfig.json. [Trace - 4:42:28 ├F10: PM┤] Received notification 'window/logMessage'. Params: { "type": 1, "message": "No config file for /Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html" } [Error - 4:42:28 ├F10: PM┤] No config file for /Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html [Trace - 4:42:41 ├F10: PM┤] Sending request 'angular/isAngularCoreInOwningProject - (1)'. Params: { "textDocument": { "uri": "file:///Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html" } } [Trace - 4:42:41 ├F10: PM┤] Received notification 'window/logMessage'. Params: { "type": 1, "message": "No config file for /Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html" } [Error - 4:42:41 ├F10: PM┤] No config file for /Users/aioiyuuko/workspaces/anduin/src/app/modules/financial/financial.component.html [Trace - 4:42:41 ├F10: PM┤] Received response 'angular/isAngularCoreInOwningProject - (1)' in 4ms. No result returned.

🌍 Your Environment

Angular Version:

v12.2.14

@angular/server Version:

v13.3.4

Nodejs Version:

v12.22.12

Extension options:

  "angular.log": "verbose",
  "angular.trace.server": "verbose",
  "angular.view-engine": false,

Anything else relevant?

Relative issue https://github.com/iamcco/coc-angular/issues/56

atscott commented 2 years ago

@iamcco I was not able to reproduce this following the steps in the original issue

  1. Make sure Node version is v12.
  2. Generate a new angular app: npx @angular/cli@13 new test-proj (default settings). (I tried v12 and v13, neither had issues)
  3. Open the project in neovim VSCode and navigate to src/app/app.component.html.
  4. Try to show hover or goto def on a binding, e.g. {{ title }}.

I double and triple checked that I was using node v12 as well.

I noticed in the logs that the language service plugin fails to activate

Info 19   [16:42:11.110] Enabling plugin @angular/language-service from candidate paths: /Users/aioiyuuko/.config/coc/extensions/node_modules/coc-angular/node_modules/@angular/language-service/index.js,/Users/aioiyuuko/workspaces/anduin/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 20   [16:42:11.110] Loading @angular/language-service from /Users/aioiyuuko/.config/coc/extensions/node_modules/coc-angular/node_modules/@angular/language-service/index.js (resolved to /Users/aioiyuuko/.config/coc/extensions/node_modules/coc-angular/node_modules/@angular/language-service/index.js/node_modules)
Info 21   [16:42:11.237] Plugin activation failed: SyntaxError: Unexpected token '?'

Do you have an example project? What version of VSCode are you using?

joeveiga commented 2 years ago

Hi @atscott . I posted the original issue to the coc-angular repo. The issue wasn't reproducible in VSCode. Could it be the case that vscode uses a different node runtime than the one installed in your system? (see https://github.com/iamcco/coc-angular/issues/56#issuecomment-1127373585)

atscott commented 2 years ago

@joeveiga Does an older version of the @angular/language-server package work? It could be helpful to pinpoint exactly what version this stopped working in.

atscott commented 2 years ago

FWIW node 12 isn't even supported anymore: https://nodejs.org/en/about/releases. v12 has been dropped from the engines list in Angular 14. I do realize we're talking about the v13 package here, but I can't imagine we'd do a ton of investigation to ensure it works again for node 12. If installing an older version of the package does the trick, that would likely be the best bet.

joeveiga commented 2 years ago

@atscott yeah I should probably push for updating the node version on my end 😅. Thanks!

iamcco commented 2 years ago

got it

angular-automatic-lock-bot[bot] commented 2 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.