npm 启动失败,lodash 类型错误

问题描述 投票:0回答:1

我无法在本地运行我的项目并假设依赖关系已损坏,但无法找到解决方案。

我在尝试安装节点模块时已经收到错误,因此我更改了以下依赖项:

“codelyzer”:“^5.1.2”到“6.0.2” “茉莉花核心”:“~3.5.0”到“^3.8.0”

当前package.json:

{
  "dependencies": {
    "@angular/animations": "^10.2.2",
    "@angular/cdk": "^10.2.7",
    "@angular/common": "^10.2.2",
    "@angular/compiler": "^10.2.2",
    "@angular/core": "^10.2.2",
    "@angular/forms": "^10.2.2",
    "@angular/material": "^10.2.7",
    "@angular/platform-browser": "^10.2.2",
    "@angular/platform-browser-dynamic": "^10.2.2",
    "@angular/platform-server": "^10.2.2",
    "@angular/router": "^10.2.2",
    "@swimlane/ngx-datatable": "^18.0.0",
    "@tinymce/tinymce-angular": "^4.2.0",
    "angular-svg-icon": "^10.0.0",
    "core-js": "^2.6.11",
    "intl": "^1.2.5",
    "jsoneditor": "^5.34.0",
    "lodash-es": "^4.17.11",
    "rxjs": "^6.6.3",
    "susy": "^2.2.14",
    "tinymce": "^4.9.11",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1002.0",
    "@angular/cli": "^10.2.0",
    "@angular/compiler-cli": "^10.2.2",
    "@angular/language-service": "^10.2.2",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "^2.0.8",
    "@types/lodash-es": "^4.14.109",
    "@types/node": "^12.11.1",
    "@types/tinymce": "^4.6.0",
    "codelyzer": "6.0.2",
    "eslint-plugin-prettier": "^2.7.0",
    "husky": "^3.1.0",
    "jasmine-core": "^3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "lint-staged": "^9.5.0",
    "prettier": "^1.19.1",
    "protractor": "~7.0.0",
    "ts-node": "~3.2.0",
    "tslint": "~6.1.0",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "4.0.5"
  }
}

节点模块的安装有效,尽管它会导致以下消息: 49 个漏洞(2 个低漏洞、19 个中漏洞、27 个高漏洞、1 个严重漏洞)

npm start
导致许多 lodash 错误:

ERROR in node_modules/@types/lodash/common/object.d.ts:1025:21 - error TS1110: Type expected.

1025         : K extends `${number}`
                         ~~~
node_modules/@types/lodash/common/object.d.ts:1026:24 - error TS1005: ':' expected.

1026             ? 'length' extends keyof T
                            ~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1026:38 - error TS1005: ';' expected.

1026             ? 'length' extends keyof T
                                          ~
node_modules/@types/lodash/common/object.d.ts:1027:26 - error TS1005: ':' expected.

1027                 ? number extends T['length']
                              ~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1028:30 - error TS1005: ':' expected.

1028                     ? number extends keyof T
                                  ~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1028:44 - error TS1005: ';' expected.

1028                     ? number extends keyof T
                                                ~
node_modules/@types/lodash/common/object.d.ts:1031:21 - error TS1128: Declaration or statement expected.

1031                     : undefined
                         ~
node_modules/@types/lodash/common/object.d.ts:1043:41 - error TS1110: Type expected.

1043     type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}`
                                             ~~~
node_modules/@types/lodash/common/object.d.ts:1043:50 - error TS1005: '}' expected.

1043     type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}`
                                                      ~~~~
node_modules/@types/lodash/common/object.d.ts:1043:55 - error TS1128: Declaration or statement expected.

1043     type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}`
                                                           ~
node_modules/@types/lodash/common/object.d.ts:1043:57 - error TS1005: ';' expected.

1043     type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}`
                                                             ~
node_modules/@types/lodash/common/object.d.ts:1043:64 - error TS1005: ';' expected.

1043     type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}`
                                                                    ~~~~~
node_modules/@types/lodash/common/object.d.ts:1046:29 - error TS1005: ';' expected.

1046             : Left extends `${infer FieldKey}[${infer IndexKey}]`
                                 ~
node_modules/@types/lodash/common/object.d.ts:1046:30 - error TS1005: ';' expected.

1046             : Left extends `${infer FieldKey}[${infer IndexKey}]`
                                  ~
node_modules/@types/lodash/common/object.d.ts:1046:37 - error TS1005: ';' expected.

1046             : Left extends `${infer FieldKey}[${infer IndexKey}]`
                                         ~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1046:48 - error TS1005: ',' expected.

1046             : Left extends `${infer FieldKey}[${infer IndexKey}]`
                                                    ~
node_modules/@types/lodash/common/object.d.ts:1046:55 - error TS1005: ',' expected.

1046             : Left extends `${infer FieldKey}[${infer IndexKey}]`
                                                           ~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1053:26 - error TS1005: ';' expected.

1053             : P extends `${infer FieldKey}[${infer IndexKey}]`
                              ~
node_modules/@types/lodash/common/object.d.ts:1053:27 - error TS1005: ';' expected.

1053             : P extends `${infer FieldKey}[${infer IndexKey}]`
                               ~
node_modules/@types/lodash/common/object.d.ts:1053:34 - error TS1005: ';' expected.

1053             : P extends `${infer FieldKey}[${infer IndexKey}]`
                                      ~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1053:45 - error TS1005: ',' expected.

1053             : P extends `${infer FieldKey}[${infer IndexKey}]`
                                                 ~
node_modules/@types/lodash/common/object.d.ts:1053:52 - error TS1005: ',' expected.

1053             : P extends `${infer FieldKey}[${infer IndexKey}]`
                                                        ~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1307:23 - error TS1005: ';' expected.

1307          * Checks if `path` is a direct property of `object`.
                           ~~~~
node_modules/@types/lodash/common/object.d.ts:1307:54 - error TS1005: ';' expected.

1307          * Checks if `path` is a direct property of `object`.
                                                          ~~~~~~
node_modules/@types/lodash/common/object.d.ts:1312:30 - error TS1005: ';' expected.

1312          * @returns Returns `true` if `path` exists, else `false`.
                                  ~~~~
node_modules/@types/lodash/common/object.d.ts:1312:40 - error TS1005: ';' expected.

1312          * @returns Returns `true` if `path` exists, else `false`.
                                            ~~~~
node_modules/@types/lodash/common/object.d.ts:1312:60 - error TS1005: ';' expected.

1312          * @returns Returns `true` if `path` exists, else `false`.
                                                                ~~~~~
node_modules/@types/lodash/common/object.d.ts:1346:23 - error TS1005: ';' expected.

1346          * Checks if `path` is a direct or inherited property of `object`.
                           ~~~~
node_modules/@types/lodash/common/object.d.ts:1346:67 - error TS1005: ';' expected.

1346          * Checks if `path` is a direct or inherited property of `object`.
                                                                       ~~~~~~
node_modules/@types/lodash/common/object.d.ts:1351:30 - error TS1005: ';' expected.

[7[39mm1351          * @returns Returns `true` if `path` exists, else `false`.
                                  ~~~~
node_modules/@types/lodash/common/object.d.ts:1351:40 - error TS1005: ';' expected.

1351          * @returns Returns `true` if `path` exists, else `false`.
                                            ~~~~
node_modules/@types/lodash/common/object.d.ts:1351:60 - error TS1005: ';' expected.

1351          * @returns Returns `true` if `path` exists, else `false`.
                                                                ~~~~~
node_modules/@types/lodash/common/object.d.ts:1751:16 - error TS1005: ';' expected.

1751          * to `undefined`. Array and plain object properties are merged recursively.
                    ~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1756:43 - error TS1005: ';' expected.

1756          * **Note:** This method mutates `object`.
                                               ~~~~~~
node_modules/@types/lodash/common/object.d.ts:1761:30 - error TS1005: ';' expected.

1761          * @returns Returns `object`.
                                  ~~~~~~
node_modules/@types/lodash/common/object.d.ts:1842:33 - error TS1005: ';' expected.

1842          * This method is like `_.merge` except that it accepts `customizer` which
                                     ~
node_modules/@types/lodash/common/object.d.ts:1842:66 - error TS1005: ';' expected.

1842          * This method is like `_.merge` except that it accepts `customizer` which
                                                                      ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1844:28 - error TS1005: ';' expected.

1844          * properties. If `customizer` returns `undefined` merging is handled by the
                                ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1844:49 - error TS1005: ';' expected.

1844          * properties. If `customizer` returns `undefined` merging is handled by the
                                                     ~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1845:33 - error TS1005: ';' expected.

1845          * method instead. The `customizer` is invoked with seven arguments:
                                     ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:1852:30 - error TS1005: ';' expected.

1852          * @returns Returns `object`.
                                  ~~~~~~
node_modules/@types/lodash/common/object.d.ts:1938:29 - error TS1005: ';' expected.

1938          * The opposite of `_.pick`; this method creates an object composed of the
                                 ~
node_modules/@types/lodash/common/object.d.ts:1939:56 - error TS1005: ';' expected.

1939          * own and inherited enumerable properties of `object` that are not omitted.
                                                            ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2000:29 - error TS1005: ';' expected.

2000          * The opposite of `_.pickBy`; this method creates an object composed of the
                                 ~
node_modules/@types/lodash/common/object.d.ts:2001:56 - error TS1005: ';' expected.

2001          * own and inherited enumerable properties of `object` that `predicate`
                                                            ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2001:70 - error TS1005: ';' expected.

2001          * own and inherited enumerable properties of `object` that `predicate`
                                                                          ~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2051:54 - error TS1005: ';' expected.

2051          * Creates an object composed of the picked `object` properties.
                                                          ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2093:47 - error TS1005: ';' expected.

2093          * Creates an object composed of the `object` properties `predicate` returns
                                                   ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2093:67 - error TS1005: ';' expected.

2093          * Creates an object composed of the `object` properties `predicate` returns
                                                                       ~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2443:33 - error TS1005: ';' expected.

2443          * This method is like `_.update` except that it accepts `customizer` which is
                                     ~
node_modules/@types/lodash/common/object.d.ts:2443:67 - error TS1005: ';' expected.

2443          * This method is like `_.update` except that it accepts `customizer` which is
                                                                       ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2444:47 - error TS1005: ';' expected.

2444          * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
                                                   ~~~~
node_modules/@types/lodash/common/object.d.ts:2444:59 - error TS1005: ';' expected.

2444          * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
                                                               ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2444:80 - error TS1005: ';' expected.

2444          * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
                                                                                    ~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2445:65 - error TS1005: ';' expected.

2445          * path creation is handled by the method instead. The `customizer` is invoked
                                                                     ~~~~~~~~~~
node_modules/@types/lodash/common/object.d.ts:2448:43 - error TS1005: ';' expected.

2448          * **Note:** This method mutates `object`.
                                               ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2456:30 - error TS1005: ';' expected.

2456          * @returns Returns `object`.
                                  ~~~~~~
node_modules/@types/lodash/common/object.d.ts:2581:1 - error TS1160: Unterminated template literal.

2581 
     

** Angular Live Development Server is listening on ... **

节点版本:16.20.2

我尝试了

--legacy-peer-deps
--force
,还有
npm audit fix
,但无论如何我收到了lodash错误

我感谢每一个帮助!

angular npm lodash npm-start
1个回答
0
投票

您可以尝试更换

typescript
中的
devDependencies
吗?:

{ “开发依赖项”:{ “打字稿”:“https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/155637/artifacts?artifactName=tgz&fileId=04DE374095785839F62F13D7F462400B471B8FC647 A291E41CD31D23BFD6186002&fileName=/typescript-5.2.0-insiders。 20230626.tgz" } }

来自:https://github.com/microsoft/TypeScript/pull/54781#issuecomment-1607903315

© www.soinside.com 2019 - 2024. All rights reserved.