Search code examples
vue.jsasp.net-corevuex

Vuex in vue .net core application


I have an ASP .NET Core project with a Vue front end. This was made using:

dotnet new — install Microsoft.AspNetCore.SpaTemplates::*

dotnet new vue

This builds and runs fine but when I try and add vuex for state management I get a list of errors.

If I add vuex by running:

npm install --save vuex

and then whenever I try and add:

import Vuex from 'vuex'

the error list looks like:

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:45 TS1005: ';' expected.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:79 TS1005: ';' expected.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:67 TS1005: ';' expected.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:100 TS1005: '=' expected.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:115 TS1005: ';' expected.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:73 TS2304: Cannot find name 'infer'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:79 TS2304: Cannot find name 'R'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:89 TS2304: Cannot find name 'R'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:5:93 TS2304: Cannot find name 'never'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:85 TS2370: A rest parameter must be of an array type.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:94 TS2304: Cannot find name 'infer'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:100 TS2304: Cannot find name 'Args'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:109 TS2304: Cannot find name 'infer'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:115 TS2304: Cannot find name 'R'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:120 TS2370: A rest parameter must be of an array type.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:129 TS2304: Cannot find name 'Args'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:138 TS2304: Cannot find name 'R'.

ERROR in [at-loader] ./node_modules/vuex/types/helpers.d.ts:8:142 TS2304: Cannot find name 'never'.

I have looked around but can't find anyone else having this problem. Looks like there's an issue with typescript and vuex? I am running the latest version of typescript in my application.

Here's my tsconfig.json

"compilerOptions": {
  "allowSyntheticDefaultImports": true,
  "experimentalDecorators": true,
  "module": "es2015",
  "moduleResolution": "node",
  "target": "es2015",
  "sourceMap": true,
  "skipDefaultLibCheck": true,
  "strict": true,
  "types": [ "webpack-env" ],
  "strictFunctionTypes": false
},
"exclude": [
  "bin",
  "node_modules"
 ]

}

Is there anything else that people are using for state management in their apps? I want to make a 'user' entity available through the components. Global mixins didn't seem to be quite right so I though vuex would do it.

Thanks


Solution

  • Have you tried running the "npm update" command from within your project? On the face of it, it seems your tsconfig.js file is fine.