Git Product home page Git Product logo

typescript-template's Introduction

Nuxt TypeScript starter template

A Nuxt 2 + @nuxt/typescript starter project template.

Setup

Create your repository by Use this template button from this template and clone into your local.

Then, run below command and follow its message.

./init.sh

The command will ask your preference for the API to write Vue component among:

  • Options API
  • Class API with with nuxt-property-decorator
  • Composition API (Experimental) with @nuxt/composition-api

Usage

Run Development server

npm run dev

Go to http://localhost:3000

Build/Run SSR enabled application

npm run build
npm start

Static Generation

Netlify Status

npm run generate #=> Then distribute /dist

FAQ

  • Q. How about providing sample usage of "xyz" (The name of OSS which you want to use)?
    • A. Recommend running into create-nuxt-app. This template aims to provide a minimal sample that follows the latest version of Nuxt.js and @nuxt/typescript.
  • Q. I think the usage of Vuex is not typed enough...?
    • A. We know! We desire the next major version of Vuex (v4) saves our bacon.

Miss the old way of this repository?

That still alives on master branch.

typescript-template's People

Contributors

9renpoto avatar alexchopin avatar atinux avatar breakingrobot avatar entyo avatar fieteboerner avatar harlan-zw avatar hmsk avatar hokaccha avatar johnlindquist avatar khrome83 avatar nokazn avatar qm3ster avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-template's Issues

Update template to use latest dependencies

Right now the template uses quite outdated version of Nuxt as well as other project dependencies. Please, update all project dependencies to use latest available packages. Upgrading manually causes issues right now

This question is available on Nuxt.js community (#c19)

This template cannot even start

$ vue init nuxt-community/typescript-template myapp
$ cd myap
$ yarn

yarn install v1.3.2
info No lockfile found.
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning " > [email protected]" has unmet peer dependency "vue@^2.5.13".
warning " > [email protected]" has unmet peer dependency "vuex@^3.0.1".
warning "nuxt-class-component > [email protected]" has unmet peer dependency "vue@^2.5.0".
warning "nuxt-class-component > [email protected]" has unmet peer dependency "vuex@^3.0.0".
warning " > [email protected]" has unmet peer dependency "vue@^2.0.0".
warning " > [email protected]" has unmet peer dependency "vuex@^2.0.0".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
โœจ  Done in 14.31s.


$ yarn dev

yarn dev
yarn run v1.3.2
$ nuxt

 WARN  ~modules/typescript.ts

Supporting callbacks is depricated and will be removed in next releases. Consider using async/await.


 ERROR

  TypeError: Cannot read property 'loaders' of undefined

  - typescript.ts:12 Builder.extendBuild.config
    /Users/hipertracker/myapp/modules/typescript.ts:12:20

  - utils.js:112 Builder.<anonymous>
    [myapp]/[nuxt]/lib/common/utils.js:112:17

  - client.config.js:208 Builder.webpackClientConfig
    [myapp]/[nuxt]/lib/builder/webpack/client.config.js:208:54

  - builder.js:485 Builder.webpackBuild
    [myapp]/[nuxt]/lib/builder/builder.js:485:46

  - builder.js:168 Builder.build
    [myapp]/[nuxt]/lib/builder/builder.js:168:16
This question is available on Nuxt.js community (#c18)

How to import a component?

When I try to import a component in pages/index.vue like this:

import MyComponent from "~components/MyComponent.vue"

@Component({
  components: {
    MyComponent,
  }
})

I got this error:

error TS2307: Cannot find module '~components/MyComponent.vue'.

~components/MyComponent.vue:

<template>
  <div>
    This is my component
  </div>
</template>

Am I missing anything?

This question is available on Nuxt.js community (#c1)

Unable to transition to process.client from context.isClient

Since the project was updated to Nuxt v. 1.3.0 I started getting a deprecation warning inside my middleware functions:
context.isClient has been deprecated, please use process.client instead.
the funny part is that I can't change my code to use process.client instead because of TS error:
TS2339: Property 'client' does not exist on type 'Process'.
so it seems like this change was made without TS in mind. How can this typing issue be fixed?

This question is available on Nuxt.js community (#c25)

[generate error] Failed at nuxt generate script.

Nice starter.

When I run the commands: npm run dev, npm run build, everything works well. But it reports an error when running the script npm run generate.

Here are logs:
log1
log2

The project has been compiled because I can find the distribution folder. It failed at rendering url "/".

In the file /store/index.js:

export const actions = {
  async nuxtServerInit({ commit }) { // <--
    const response = await axios.get("/random-data.json");
    const people = response.data.slice(0, 10);
    commit("setPeople", people);
  },
  select({ commit }, id) {
    commit("select", id);
  }
};

I edit it to that:

export const actions = {
  async fetch({ commit }) { // <-- change nuxtServerInit() to fetch()
    const response = await axios.get("/random-data.json");
    const people = response.data.slice(0, 10);
    commit("setPeople", people);
  },
  select({ commit }, id) {
    commit("select", id);
  }
};

Then it works:
log3

I want to know the reasons why it crashes when there exists the function nuxtServerInit()..
Thank you.

This question is available on Nuxt.js community (#c4)

TypeError: Cannot read property 'loaders' of undefined

Fresh install from vue-cli

installed packages

After npm run dev I got this.

TypeError: Cannot read property 'loaders' of undefined
  
  - typescript.ts:12 Builder.extendBuild.config
    ~/site-v2/modules/typescript.ts:12:20
  
  - utils.js:77 Builder.<anonymous>
    [site-v2]/[nuxt]/lib/common/utils.js:77:17
  
  - client.config.js:223 Builder.webpackClientConfig
    [site-v2]/[nuxt]/lib/builder/webpack/client.config.js:223:54
  
  - builder.js:372 Builder._callee5$
    [site-v2]/[nuxt]/lib/builder/builder.js:372:46
  
  - builder.js:173 Builder._callee$
    [site-v2]/[nuxt]/lib/builder/builder.js:173:16
This question is available on Nuxt.js community (#c12)

Cannot read property 'loaders' of undefined

After executing the following commands:

vue init nuxt-community/typescript-template hello-nuxt
cd hello-nuxt
yarn
yarn dev (or npm run dev)

I'm getting the following error:

TypeError: Cannot read property 'loaders' of undefined

Logs from the last command:

yarn dev v0.27.5
$ nuxt
  nuxt:build App root: /home/user/testing/vue/hello-nuxt +0ms
  nuxt:build Generating /home/user/testing/vue/hello-nuxt/.nuxt files... +2ms
  nuxt:build Generating files... +10ms
  nuxt:build Generating routes... +8ms
  nuxt:build Building files... +26ms
  TypeError: Cannot read property 'loaders' of undefined
  
  - typescript.ts:12 Builder.extendBuild.config
    /home/user/testing/vue/hello-nuxt/modules/typescript.ts:12:19
  
  - utils.js:77 Builder.<anonymous>
    [hello-nuxt]/[nuxt]/lib/common/utils.js:77:17
  
  - client.config.js:223 Builder.webpackClientConfig
    [hello-nuxt]/[nuxt]/lib/builder/webpack/client.config.js:223:54
  
  - builder.js:372 Builder._callee5$
    [hello-nuxt]/[nuxt]/lib/builder/builder.js:372:46
  
  - builder.js:173 Builder._callee$
    [hello-nuxt]/[nuxt]/lib/builder/builder.js:173:16

Versions:

  • node: 8.4.0
  • npm: 5.3.0
  • yarn: 0.27.5
  • vue: 2.8.2
  • typescript: 2.5.2

Any suggestions on how I can resolve this?

This question is available on Nuxt.js community (#c10)

TypeScript template has error when installing in latest version

NOTE - Link to nuxtjs.cmty.io failed. Posting without using 3rd party app, please do not delete.

Version

v2.6.1

Reproduction link

Following install instructions in README.md
No other changes

Steps to reproduce

Following install instructions in README.md
No other changes

What is expected?

TypeScript works as expected...

What is actually happening?

pages/index.vue file throws a TypeScript error -
@State people:Person gives a error.

Screen Shot 2019-04-17 at 7 12 47 AM

components/Card.vue file throws a TypeScript error -
@Prop() person: Person gives a error.

Screen Shot 2019-04-17 at 7 12 37 AM

Additional comments?

The code is copied and pasted exactly.

This question is available on Nuxt community (#c49)

Property 'BROWSER_BUILD' does not exist on type 'Process'.

Hi

I have a error

TS2339: Property 'BROWSER_BUILD' does not exist on type 'Process'.

in these code
image

And when change process.BROWSER_BUILD for (<any>process).BROWSER_BUILD by (<any>process).BROWSER_BUILD it do another error

image

I don't know how to resolve..

Thanks

This question is available on Nuxt.js community (#c5)

Can't access $route.params in TS class

I've created a dynamically routed page _id.vue inside of my pages folder and I want to have access to that id property inside of my TS class. I can access it in my template by writing {{$route.params.id}} but when I try to reference $route inside of the class I get an error:
error TS2304: Cannot find name '$route'.
I've tried to reference it using this like so
this.$route.params
but then I get TS precompile error:
error TS2339: Property '$route' does not exist on type 'default'.
I also tried to reference it without a $ sign like so
this.route.params
but still got the same error.
How can I access route params?

This question is available on Nuxt.js community (#c16)

asyncData not working

Version

2.0

Reproduction link

https://jsfiddle.net/odzj1304/

Steps to reproduce

asyncData method not update property or print anything to console if i type console.log...

What is expected ?

Change title variable to "Test"

What is actually happening?

Leave title "A"

This bug report is available on Nuxt community (#c48)

GitHub issue template points to wrong CMTY app address

Version

v2.12.2

Reproduction link

https://github.com/nuxt-community/typescript-template/issues/new

Steps to reproduce

  1. Open a new issue on Github: https://github.com/nuxt-community/typescript-template/issues/new
  2. Read the issue template, note it says: IMPORTANT: Please use the following link to create a new issue: https://nuxtjs.cmty.io/issues/new
  3. Access the URL being pointed to
  4. Get a DNS name resolution error

What is expected ?

Should point to correct URL: https://cmty.app/nuxt/issues/new?type=bug-report&repo=typescript-template

What is actually happening?

Being pointed to nonexistent URL https://nuxtjs.cmty.io/issues/new

This bug report is available on Nuxt community (#c57)

Cannot resolve definitions for module nuxt-class-component

I'm using this template inside Webstorm and once I'm trying to import nuxt-class-component into my project I get a reference highlight in red giving me an error: Cannot resolve definitions for module nuxt-class-component
image

When I try to fix it by importing a related @typed definition package
image

I get another error:
image

I tried to look for a related definition manually but seems like it doesn't exist in the @types repo.
Could someone help me fix this issue?

This question is available on Nuxt.js community (#c20)

What is it the better snippet (highlight extension) for VSC?

Hi

I am working with VSC, nuxtjs and typescript, but in the .vue files I can't to see very well the syntax, I installed Vuter, but always it show this error

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

also, some any another errors that in .ts files aren't shows

Thanks

This question is available on Nuxt.js community (#c2)

Remove unneeded project dependencies

I don't see any reason for keeping these dependencies as root level:

"vue": "^2.5.13",
"vue-meta": "^1.4.2",
"vuex": "^3.0.1",
"vue-router": "^3.0.1",
"webpack": "^3.10.0"

all of those already have been installed by nuxt internally.

as I've highlighted in this issue #31 these dependencies won't be needed when we'll move to nuxt-property-decorator

"vue-property-decorator": "^6.0.0",
"vue-class-component": "^6.1.2",
"nuxt-class-component": "^1.2.0",

These dependencies are also under a question since they don't really relate to a TypeScript template idea and might be made optional to install during template initialization process for users who really like them to be in their template. ( I personally would also like to have SASS support as an option) #32

"gsap": "^1.20.3",
"tachyons": "^4.9.1",
"axios": "^0.17.1",

So, ideally, we should have only these dependencies installed by default:

"dependencies": {
    "nuxt": "^1.3.0",
    "nuxt-property-decorator": "^1.0.0",
    "vuex-class": "^0.3.0"
  },
This question is available on Nuxt.js community (#c28)

fresh project, followed the directions, failed at npm run dev

$ npm run dev

@1.0.1 dev /home/bkinsey/opt/gh/bkinsey808/vue-nuxt-experiment
nuxt

nuxt:build App root: /home/bkinsey/opt/gh/bkinsey808/vue-nuxt-experiment +0ms
nuxt:build Generating .nuxt/ files... +2ms
events.js:161
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE 127.0.0.1:3000
at Object.exports._errnoException (util.js:1028:11)
at exports._exceptionWithHostPort (util.js:1051:20)
at Server._listen2 (net.js:1261:14)
at listen (net.js:1297:10)
at doListening (net.js:1396:7)
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:422:7)
at startup (bootstrap_node.js:143:9)
at bootstrap_node.js:537:3

This question is available on Nuxt.js community (#c7)

Cannot deploy to Netlify

Hi, I'm encountering an error when trying to deploy this template to Netlify.

This error appears in the deployment log, although it still completes and marks the deployment as succesful:
screenshot from 2018-03-02 11-34-41

After deployment, this is all that appears when following the genrated URL (https://hardcore-curie-c8f6ae.netlify.com)
screenshot from 2018-03-02 11-35-20

I'm not sure if there's something wrong with the template itself or my deployment.

Steps to recreate:

  1. $ vue init nuxt-community/typescript-template my-project OR clone my repo of the same: $ git clone https://github.com/salvadornico/nuxt-ts-test.git
  2. Add to Github as a new repository
  3. Create new site on Netlify, connecting this new repo
  4. For deployment settings: yarn generate as build command, dist as publish directory
  5. Deploy site

Thanks for the help!

This question is available on Nuxt.js community (#c35)

Saperate the script in vue files to .ts files.

Hi guys.

Is it pobbile to split .vue files under /pages and keep the script in .ts file and the template in .vue files.

am trying to split the html and the script part.

the /pages can have
/pages/index.vue
/pages/index.ts

index.vue - can have reference to script

Nuxt TypeScript Starter
Selected Person: {{selectedPerson.first_name}} {{selectedPerson.last_name}} is #{{selected}}
</div>
<div class="flex flex-wrap ph2 justify-between bg-white-80">
  <div :key="person.id" v-for="person in people">
    <Card :person="person"></Card>
  </div>
</div>
**<script src="./index.ts"></script>**

is the above currently possible ?

This question is available on Nuxt.js community (#c32)

Nuxt Edge - Issue when running/building the project

Version

latest

Reproduction link

[not required](not required)

Steps to reproduce

  • Create a normal typescript project by vue init nuxt-community/typescript-template my-project
  • Replace nuxt dependencies with nuxt-edge
  • Replace ts-loader with latest version of ts-loader (compatible with webpack 4.x)
  • Run command nuxt dev

What is expected ?

The app to start normally as per this https://medium.com/nuxt/nuxt-2-is-coming-oh-yeah-212c1a9e1a67 which states no changes required for updating a nuxt 1.x project with nuxt 2.x project

What is actually happening?

Receiving an error

 INFO  Building project

โœ” success Builder initialized
โœ” success Nuxt files generated
โœ– error TypeError: Cannot set property 'ts' of undefined
  at Builder.extendBuild.config (/Users/naveen/Downloads/nuxt/ts/modules/typescript.js:24:33)
  at Builder.<anonymous> (/usr/local/lib/node_modules/nuxt-edge/dist/nuxt.js:142:17)
  at WebpackClientConfig.config (/usr/local/lib/node_modules/nuxt-edge/dist/nuxt.js:11310:56)
  at Builder.webpackBuild (/usr/local/lib/node_modules/nuxt-edge/dist/nuxt.js:11881:56)
  at Builder.build (/usr/local/lib/node_modules/nuxt-edge/dist/nuxt.js:11592:16)
  at <anonymous>
This bug report is available on Nuxt.js community (#c38)

Can't import `.ts` files

Working:

  • Importing .vue files with lang="ts"
  • Import .js files

Not working

  • Importing .ts files
This question is available on Nuxt.js community (#c6)

[Critical] - Build is failing. Missing dependency nuxt-property-decorator

Steps to reproduce:
Clone repo using vue-cli
Install dependency with npm/yarn
Run npm run dev

ERROR Failed to compile with 2 errors12:32:38

This dependency was not found:

  • nuxt-property-decorator in ./node_modules/ts-loader?{"appendTsSuffixTo":[{}]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./components/Card.vue, ./node_modules/ts-loader?{"appendTsSuffixTo":[{}]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./pages/index.vue

To install it, you can run: npm install --save nuxt-property-decorator

nuxt-property-decorator is present in node_modules folder, but it seems that it's broken. It references some unexistent entry point in package.json nuxt-property-decorator.umd
I have strong doubts on whether it should be used instead of nuxt-class-component + vue-property-decorator although it seems logical, the dependency itself is quite problematic

This question is available on Nuxt.js community (#c33)

How to use namespaced stores with this starting template?

I want to use namespaced stores inside my project. According to Nuxt documentation provided here: https://nuxtjs.org/guide/vuex-store/
namespaced stores should be created automatically after a file is placed inside store folder. But in my case, it doesn't work.
Steps I do:

  1. Create a file todos.ts inside store folder
import axios from "~plugins/axios/api"
import {TodosState, Todo, TodoActions, TodoGetters, TodoMutations} from '~/types/todos'
import {AxiosResponse} from 'axios'

export const state = () => ({
    todos: []
} as TodosState)

export const mutations:TodoMutations = {
    add(state:TodosState, todo:Todo){
        state.todos.push(todo)
    },
    remove(state:TodosState, todo:Todo){
        state.todos = state.todos.filter(t => t.id !== todo.id)
    }
}

export const actions:TodoActions = {
    async add({commit}, task){
        const {data}:AxiosResponse<any> = await axios.post('/todos', {task, complete: false})
        commit('add', data)
    },
    async remove({commit}, todo:Todo){
        await axios.delete(`/todos/${todo.id}`)
        commit('remove', todo)
    }
}

export const getters:TodoGetters = {
    active: state => state.todos.filter(t => !t.complete),
    complete: state => state.todos.filter(t => t.complete),
}
  1. In my index.vue page I try to use namespaced store:
<script lang="ts">
    import Vue from "vue";
    import Component from "nuxt-class-component"
    import {State, Action, namespace} from "vuex-class"
    import init from '~assets/ts/init'
    import {Todo} from '../types/todos'

    const TodosState = namespace('todos', State);
    const TodosAction = namespace('todos', Action);

    @Component({
        fetch: init
    })
    export default class extends Vue {
        task = ""
        @TodosState todos:Todo[]
        @TodosAction('add') _add
        @TodosAction remove

        add(task){
            this._add(task);
            this.task = "";
        }
    }
</script>

but I get no data and no errors in a console, build process is also fine.
Are there any additional configs I have to make in order to use namespaced store?

This question is available on Nuxt.js community (#c21)

How do i can debug it in VS Code?

Hi there,

I'm in windows and used this configuration, but the app doesn't run:

// .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "client: chrome",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "server: nuxt",
            "args": ["dev"],
            "osx": {
                "program": "${workspaceFolder}/node_modules/.bin/nuxt-ts"
            },
            "linux": {
                "program": "${workspaceFolder}/node_modules/.bin/nuxt-ts"
            },
            "windows": {
                "program": "${workspaceFolder}/node_modules/.bin/nuxt-ts"
            }
        }
    ],
    "compounds": [
        {
            "name": "fullstack: nuxt",
            "configurations": ["server: nuxt", "client: chrome"]
        }
    ]
}

is any idea how it would be?

This question is available on Nuxt community (#c54)

vue-dev-tools do not work

Version

6af12b03f798c7a0a50c209a98a833ac57753402

Reproduction link

https://github.com/nuxt-community/typescript-template

Steps to reproduce

Before running make sure that vue-dev-tools is installed in your browser.

  1. Run npx vue-cli init nuxt-community/typescript-template my-ts-project
  2. Run npm install
  3. Run npm run dev and visit localhost:3000
  4. Open dev tools

What is expected ?

I expect that my state, my components, and my event will be shown.

What is actually happening?

ะกะฝะธะผะพะบ ัะบั€ะฐะฝะฐ 2018-04-14 ะฒ 10.45.39.png
ะกะฝะธะผะพะบ ัะบั€ะฐะฝะฐ 2018-04-14 ะฒ 10.45.43.png
Nothing is shown. All tabs are empty.
ะกะฝะธะผะพะบ ัะบั€ะฐะฝะฐ 2018-04-14 ะฒ 10.45.49.png

Additional comments?

Other apps work fine.

This bug report is available on Nuxt.js community (#c36)

Interface 'NuxtApp' incorrectly extends interface 'Vue'. Types of property '$loading' are incompatible.

Version

v2.12.1

Reproduction link

https://github.com/finntenzor/congenial-parakeet

Steps to reproduce

npx create-nuxt-app akblog
cd akblog
yarn dev

What is expected ?

Runs successfully

What is actually happening?

119:18 Interface 'NuxtApp' incorrectly extends interface 'Vue'.
Types of property '$loading' are incompatible.
Type 'NuxtLoading' is not assignable to type '(options: LoadingServiceOptions) => ElLoadingComponent'.
Type 'DefaultNuxtLoading' is not assignable to type '(options: LoadingServiceOptions) => ElLoadingComponent'.
Type 'DefaultNuxtLoading' provides no match for the signature '(options: LoadingServiceOptions): ElLoadingComponent'.
117 | }
118 |

119 | export interface NuxtApp extends Vue {
| ^
120 | $options: NuxtAppOptions
121 | $loading: NuxtLoading
122 | context: Context

i Version: typescript 3.8.3

Additional comments?

Actually, "yarn build" doesn't work, either.

119:18 Interface 'NuxtApp' incorrectly extends interface 'Vue'.
Types of property '$loading' are incompatible.
Type 'NuxtLoading' is not assignable to type '(options: LoadingServiceOptions) => ElLoadingComponent'.
Type 'DefaultNuxtLoading' is not assignable to type '(options: LoadingServiceOptions) => ElLoadingComponent'.
Type 'DefaultNuxtLoading' provides no match for the signature '(options: LoadingServiceOptions): ElLoadingComponent'.
117 | }
118 |

119 | export interface NuxtApp extends Vue {
| ^
120 | $options: NuxtAppOptions
121 | $loading: NuxtLoading
122 | context: Context

FATAL Nuxt build error 09:02:33

at WebpackBundler.webpackCompile (node_modules@nuxt\webpack\dist\webpack.js:5351:21)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at WebpackBundler.build (node_modules@nuxt\webpack\dist\webpack.js:5300:5)
at Builder.build (node_modules@nuxt\builder\dist\builder.js:5602:5)
at Object.run (node_modules@nuxt\cli\dist\cli-build.js:104:7)
at NuxtCommand.run (node_modules@nuxt\cli\dist\cli-index.js:2759:7)

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ โœ– Nuxt Fatal Error โ”‚
โ”‚ โ”‚
โ”‚ Error: Nuxt build error โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This bug report is available on Nuxt community (#c56)

Nuxt.js fetch functionality

What problem does this feature solve?

https://nuxtjs.org/api/pages-fetch/

I would like support for the above Nuxt.js function such that the following code works:

export default Vue.extend({
  ...

  async fetch({ store }) {
    await store.dispatch('someAction');
  }
  ...
})

Currently, this is met with a TS2345 error since the argument is not declared in the Vue.js Typescript definitions. I'm not sure if the onus is on Nuxt here, or whether the Vue.js typescript project should offer something more general?

This feature request is available on Nuxt community (#c41)

Example without class-style components

This example uses class-style components and property decorators. Is there an example without those?

From vue-cli 3 default not using the class-style components:

<template>
  <div class="home">
    <img src="../assets/logo.png">
    <HelloWorld msg="Welcome to Your Vue.js App"/>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src

export default Vue.extend({
  name: 'home',
  components: {
    HelloWorld,
  },
});
</script>
This question is available on Nuxt.js community (#c27)

Running an instance on the custom port is not working correctly

I want to run Nuxt TS project on the custom port, say localhost:3333. According to Nuxt official documentation in order to do so, I need to specify Nuxt settings inside options object in my package.json file like so:
"config": {
"nuxt": {
"port": "3333"
}
}
but once done I'm starting to get an error:

Error: connect ECONNREFUSED 127.0.0.1:3000 at Object._errnoException (util.js:1041:11) at _exceptionWithHostPort (util.js:1064:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1153:14)
After some investigation I've also changed env.baseUrl to also be on the 3333 port like so:
env: { baseUrl: process.env.BASE_URL || 'http://localhost:3333' }

but such approach is not optimal cos I have to specify that port in 2 places. How can I make the setup respect the port setting that is specified in config.json file?

This question is available on Nuxt.js community (#c14)

How to use head?

I can to see that the registerHooks in nuxt-class-component file, are not register the head for to change the attrs of header

This question is available on Nuxt.js community (#c3)

Change api to middleware

That's just a suggestion. Since we don't have any example of a middleware inside a template but we use an undocumented api folder which is just a discrepant addition in my opinion. Why not use middleware as Nuxt intended? api/people.ts can be placed in middleware folder and rewritten as such:

export default async function({store, error, redirect}){
    if(process.client) return;
    await store.dispatch('getPeople')
}

and in the store actions:

async getPeople({commit}){
            commit('setPeople', await axios.get('/random-data.json').data.slice(0,3));
    }

and in nuxt.config.js module.exports object

router: {
    middleware: 'people'
  },

this way we can showcase how middleware function can be used in the template that might be beneficial for a lot of users

This question is available on Nuxt.js community (#c30)

Not compatible with nuxt 2.0.0

Version

2.0.0

Reproduction link

https://github.com/nuxt-community/typescript-template

Steps to reproduce

vue init nuxt-community/typescript-template my-project
cd my-project
npm i -S [email protected]
npm install
npm run dev

What is expected ?

Working nuxt.js installation with TypeScript support.

What is actually happening?

TypeError: Cannot set property 'ts' of undefined
  at Builder.extendBuild.config (modules/typescript.js:24:33)
  at Builder.<anonymous> (node_modules/nuxt/dist/nuxt.js:155:17)
  at WebpackClientConfig.extendConfig (node_modules/nuxt/dist/nuxt.js:3126:56)
  at WebpackClientConfig.extendConfig (node_modules/nuxt/dist/nuxt.js:3258:26)
  at WebpackClientConfig.config (node_modules/nuxt/dist/nuxt.js:3164:33)
  at WebpackClientConfig.config (node_modules/nuxt/dist/nuxt.js:3292:26)
  at Builder.webpackBuild (node_modules/nuxt/dist/nuxt.js:3879:56)
  at Builder.build (node_modules/nuxt/dist/nuxt.js:3590:16)
  at <anonymous>
This bug report is available on Nuxt community (#c44)

When using this inside the head() function of a component, this does not let you access computed

Version

v2.14.4

Reproduction link

https://github.com/Esurnir/real-world-nuxt/tree/this_typing_repro

Steps to reproduce

Clone the repository.
Install dependencies with "yarn"
Run the server with yarn dev.
Check the _id.vue file in visual studio code with Vetur.

What is expected ?

No typescript error get emitted when running the server.
No typescript error in Vetur.

What is actually happening?

In the console output I get :
TS2339: Property 'id' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.
14 | head() {
15 | return {

16 | title: "Event #" + this.id,
| ^^
17 | meta: [
18 | {
19 | hid: "description",

in visual studio code I get "Property 'id' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.Vetur(2339)"

Additional comments?

I can go around it by using this.$route.params.id which is properly typed. I've already added type annotation to the id.
I can of course do (this as any).id but that defeats the purpose of the typings.

This bug report is available on Nuxt community (#c59)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.