nodebook icon indicating copy to clipboard operation
nodebook copied to clipboard

install and first run are hard to get right

Open talkingtab opened this issue 5 years ago • 3 comments

ubuntu 19:10

  • download release from github to clean directory
  • chmod +x nodebook*
  • mkdir books ./nodebook* web books click new, choose nodejs click run

` Ready. --- Running... internal/modules/cjs/loader.js:895 throw err; ^ Error: Cannot find module '/other/clones/nodebook/notebook/Waspbutter Robin/notebook/Waspbutter Robin/index.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15) at Function.Module._load (internal/modules/cjs/loader.js:785:27) at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12) at internal/main/run_main_module.js:16:11 { code: 'MODULE_NOT_FOUND', requireStack: [] } exit status 1 --- Done.

`

talkingtab avatar Feb 17 '20 14:02 talkingtab

Command line was . ./nbk web ./books but it works with ./nbk web /other/work/nbk/books

talkingtab avatar Feb 17 '20 14:02 talkingtab

Yes, I agree, something has to be done there. For cli mode; It'd also be nice to be able to:

  • run within a notebook (any dir containing one of the recognized entry points) and be able to run it, not just from the root of the notebook hierarchy as it is the case right now

  • detect newly created notebooks (for instance, from vim) and register them / watch them on the fly

netgusto avatar Feb 17 '20 15:02 netgusto

A patch to use the absolute path. In your code the possible error was wrapped but I did not do that so you might want to modify that

diff --git a/src/core/baseservices.go b/src/core/baseservices.go
index f5e56bb..1330570 100644
--- a/src/core/baseservices.go
+++ b/src/core/baseservices.go
@@ -3,6 +3,7 @@ package core
 import (
        "fmt"
        "os"
+    "path/filepath"
 
        "github.com/netgusto/nodebook/src/core/shared/recipe"
        "github.com/netgusto/nodebook/src/core/shared/service"
@@ -14,8 +15,14 @@ func baseServices(notebooksPath string) (*service.RecipeRegistry, *service.Noteb
        recipeRegistry := service.NewRecipeRegistry()
        recipe.AddRecipesToRegistry(recipeRegistry)
 
+    absBookPath, err := filepath.Abs(notebooksPath)
+    if err != nil {
+        fmt.Println("Could not get absolute path")
+        os.Exit(1)
+    }
+
        // Notebook registry
-       nbRegistry := service.NewNotebookRegistry(notebooksPath, recipeRegistry)
+       nbRegistry := service.NewNotebookRegistry(absBookPath, recipeRegistry)
 
        // Find notebooks
        notebooks, err := nbRegistry.FindNotebooks(nbRegistry.GetNotebooksPath())

talkingtab avatar Feb 17 '20 17:02 talkingtab