Skip to content

TypeError: hugo.createServer is not a function when trying to start Hugo #2

@brunogirin

Description

@brunogirin

I'm trying to create a brand new Hugo project with node-hugo and I'm failing at the first hurdle, which is to start the development server. I get the following error:

$ npm start

> [email protected] start
> ./bin/start.js

hello start
/home/bruno/Projects/carbondb/carbondb.gitlab.io/bin/start.js:10
const hugoServerProcess = hugo.createServer()
                               ^

TypeError: hugo.createServer is not a function
    at Object.<anonymous> (/home/bruno/Projects/carbondb/carbondb.gitlab.io/bin/start.js:10:32)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

The full script is:

#!/usr/bin/env node

console.log("hello start");

const Hugo = require('@small-tech/node-hugo')

const hugo = new Hugo()

// Start Hugo server. Returns a ChildProcess instance.
const hugoServerProcess = hugo.createServer()
hugoServerProcess.on('error', (error) => {
  console.log('Hugo server encountered an error', error)
})
hugoServerProcess.stdout.on('data', (data) => {
  console.log(`[Hugo] ${data}`)
})
hugoServerProcess.stderr.on('data', (data) => {
  console.log(`[Hugo] [ERROR] ${data}`)
})
hugoServerProcess.on('close', (code) => {
  console.log('Hugo server process exited with code', code)
})

And the package.json is:

{
  "name": "carbondb.gitlab.io",
  "version": "1.0.0",
  "description": "Documentation and main web resources for the Carbon DB project.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "./bin/start.js"
  },
  "repository": {
    "type": "git",
    "url": "git+ssh://[email protected]/carbondb/carbondb.gitlab.io.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://gitlab.com/carbondb/carbondb.gitlab.io/issues"
  },
  "homepage": "https://gitlab.com/carbondb/carbondb.gitlab.io#readme",
  "dependencies": {
    "@small-tech/node-hugo": "^2.0.0"
  }
}

It may just be a case of updating the README if the function was changed in v2.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions