Repository koa-template

Benleie

Benleie resolved the question #c35

koa-template • 3 days ago

compile error when dev

so i have to use nuxt@1.4.x to fix it

Benleie

Benleie posted a new question

koa-template • 3 days ago

compile error when dev

After installation,when npm run dev
Error: Plugin/Preset files are not allowed to export objects, only functions.
image

And i updated backpack-core to 0.7.0, but this error still exists.

wen-dong

wen-dong posted a new question

koa-template • 9 days ago

error in ./server/index.js

module build failed: Error: Plugin/Preset files are not allowed to export objects, only function.
In node_modules\backpack-core\babel.js

zgunz42

zgunz42 posted a new question

koa-template • 13 days ago

Failed to Start Dev

After first install the template i got this error

CMD:
yarn dev

OUTPUT

 ERROR  Failed to compile with 1 errors                                                                                                                  11:50:11

 error  in ./server/index.js

Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /home/ubuntu/workspace/node_modules/backpack-core/babel.js
    at createDescriptor (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
    at items.map (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at passPerPreset (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:58:96)
    at cachedFunction (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/caching.js:33:19)
    at presets.presets (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-descriptors.js:29:84)
    at mergeChainOpts (/home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-chain.js:315:26)
    at /home/ubuntu/workspace/node_modules/@babel/core/lib/config/config-chain.js:278:7

module.js:549
    throw err;
    ^

Error: Cannot find module '/home/ubuntu/workspace/build/main.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
eugeneCN

eugeneCN posted a new question

koa-template • a month ago

babel error

`
cd koa-template
npm install
npm run dev

Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/eMule/Desktop/koa-template/node_modules/backpack-core/babel.js
`

mrxu0

mrxu0 posted a new question

koa-template • a month ago

Production caused the file directory to change using require error
import { resolve } from 'path'
const r = path => resolve(__dirname, path)
require(r('./middlewares/general'))

error

/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:243
        return !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
                                                           ^
Error: Cannot find module "."
    at webpackMissingModule (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:243:60)
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:243:18
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_pipe.js:3:14
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_pipe.js:3:27
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_arity.js:5:45
    at _map (/Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_map.js:6:19)
    at map (/Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/map.js:57:14)
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_dispatchable.js:39:15
    at /Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_curry2.js:20:46
    at f1 (/Users/xuyuechao/Work/other-git-project/nuxt-koa/node_modules/[email protected]@ramda/src/internal/_curry1.js:17:17)
    at new Server (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:228:5)
    at Object.<anonymous> (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:306:11)
    at Object.<anonymous> (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:308:30)
    at __webpack_require__ (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:22:30)
    at module.exports.module.exports.head.title (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:68:18)
    at Object.<anonymous> (/Users/xuyuechao/Work/other-git-project/nuxt-koa/build/main.js:3:10)

How can I avoid this? The solution I came up with is 1. Change the packing method, and the file directory remains unchanged. 2. Be able to modify these imports into a packaged path。 But don't know how to change webpack

Leesson

Leesson posted a new question

koa-template • a month ago

how should I open node debug

I want to debug my scripts on port 3000. And I modified the dev script in package.json with this:

"dev": "backpack dev --inspect-brk=3000"

But it show me an error when i run the script:

listen EADDRINUSE 127.0.0.1:3000

How should i open it? thx.

renoirb

renoirb posted a new question

koa-template • 2 months ago

Document how to also make Koa match Nuxt's router.base

Assuming a project needs to have both Nuxt and Koa to answer to non-root routes, it is unclear how we can make Koa also support setting a baseUrl to something else than root / (e.g. /foo/).

Use case

Ability to support running production build to something else than root /.

// nuxt.config.js
module.exports = {
  router: {
    base: '/foo/'
  }
}

As documented in nuxt.js/…/configuration-router

Issue

Koa has no way of knowing the setting change.

TODO

  1. Setup sample repository (see renoirb/experiments-nuxt-koa-env-runtime-201806, branch rework-hare-20180619 as a starting point)
shalldie

shalldie posted a new bug report

koa-template • 3 months ago

bug compile error when titleTemplate is a function

Version

vue-cli

Reproduction link

https://github.com/shalldie/nuxt-koa-tpl-err

Steps to reproduce

  1. npm install

  2. npm run dev

What is expected ?

compile successfully and the title is ok.

What is actually happening?

compile error when titleTemplagte is a function

Additional comments?

after vue init nuxt-community/koa-template demo and npm intall

in nuxt.config.js, i add this:

  head: {
    title: '',
    titleTemplate: titleChunk => {
      // If undefined or blank then we don't need the hyphen
      return titleChunk ? `${titleChunk} - wqnmlgbd >_<#@!` : 'wqnmlgbd >_<#@!';
    },
  ...

when i try npm run dev, an error appears:

err.png

shalldie

shalldie posted a new question

koa-template • 3 months ago

compile error when titleTemplagte is a function

vue-cli version: 2.9.6

command: vue init nuxt-community/koa-template demo

in nuxt.config.js, i add this:

  head: {
    title: '',
    titleTemplate: titleChunk => {
      // If undefined or blank then we don't need the hyphen
      return titleChunk ? `${titleChunk} - wqnmlgbd >_<#@!` : 'wqnmlgbd >_<#@!';
    },
  ...

when i try npm run dev, an error appears:

image

bihaiyouhong12

bihaiyouhong12 posted a new question

koa-template • 4 months ago

"titleTemplate" cannot be set to a function

When I set the "head.titleTemplate" in "nuxt.config.js" to a function, and run the command "npm run dev", It throws an error:
image

alanisme

alanisme posted a new question

koa-template • 4 months ago

Why middleware return 'Promise' in `./server/index.js`? Where does 'resolve' and 'reject' come from?

app.use(async (ctx, next) => { await next() ctx.status = 200 // koa defaults to 404 when it sees that status is unset return new Promise((resolve, reject) => { ctx.res.on('close', resolve) ctx.res.on('finish', resolve) nuxt.render(ctx.req, ctx.res, promise => { // nuxt.render passes a rejected promise into callback on error. promise.then(resolve).catch(reject) }) }) })

wscj

wscj posted a new question

koa-template • 5 months ago

No parser and no filepath given

My node.js version is v8.9.4
when I run npm run dev, the console warned:
No parser and no filepath given, using 'babylon' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.

Just a warning, ignore it ?

moedong

moedong posted a new question

koa-template • 6 months ago

SyntaxError: Unexpected token ...

When I enter “run npm dev”,Console display:

DONE Compiled successfully in 655ms 11:59:05

E:\node\koa-nuxt\node[email protected]@nuxt\lib\core\middleware\nuxt.js:72 const policies = this.options.render.csp.policies ? {…this.options.rende r.csp.policies} : null ^^^ SyntaxError: Unexpected token … at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at Module.compile (module.js:543:28)
at Object.Module.extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module.load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\node\koa-nuxt\[email protected]@nuxt\lib\co
re\renderer.js:19:24)

yoyoys

yoyoys posted a new question

koa-template • 7 months ago

regeneratorRuntime is not defined

Node version: v9.5.0
Vue Cli: 2.9.3

I've just init this template by follow these steps: (alse tried by yarn)
vue init nuxt-community/koa-template nuxt-koa-test
npm install
npm run dev

and i got errors like this

 ERROR  Failed to compile with 1 errors                                                                                     

 error  in ./server/index.js

Module build failed: Error: Couldn't find preset "env" relative to directory
.....
/Users/Yoyo/github/nuxt-koa-test/build/main.js:216
}();
 ^
ReferenceError: regeneratorRuntime is not defined
    at /Users/Yoyo/github/nuxt-koa-test/build/main.js:135:46

And i tried to add a .babelrc file, like this:

{
  "presets": ["env"]
}

Then the first error message gone, but the second error still.
Is that a polyfill problem?

Thanks for help!

rlataguerra

rlataguerra posted a new question

koa-template • 8 months ago

No Generate commande

the readme inside the template talks about a npm run generate command while there is none in package.json

https://github.com/nuxt-community/koa-template/blob/master/template/README.md
https://github.com/nuxt-community/koa-template/blob/master/template/package.json

Jokcy

Jokcy posted a new question

koa-template • 9 months ago

Nuxt build restart everytime server code updated

I guess it's not a best practice when develop. Any plan to update the setup?

maodouchen

maodouchen posted a new question

koa-template • 10 months ago

build slow

image
when i change my code, it took too long time to build

1peng

1peng posted a new question

koa-template • a year ago

When I use ajax crossdomain request koa api,the api is the status code 404

I think these code is not work with the method OPTION.

app.use(ctx => { ctx.status = 200 // koa defaults to 404 when it sees that status is unset return new Promise((resolve, reject) => { ctx.res.on('close', resolve) ctx.res.on('finish', resolve) nuxt.render(ctx.req, ctx.res, promise => { // nuxt.render passes a rejected promise into callback on error. promise.then(resolve).catch(reject) }) }) })

k55783637

k55783637 posted a new question

koa-template • a year ago

How can I start the project with pm2? (on CentOS)

I execute the command: 'pm2 start ./build/main.js'
on Windows is ok
but on CentOS: It prompted service is refused