diff --git a/create-app.ts b/create-app.ts
index 6c684d9decf6718a91970f7cbedf333545af6f65..4c1eaf4db18322acc92d88f628dd54391cc8f093 100644
--- a/create-app.ts
+++ b/create-app.ts
@@ -11,6 +11,7 @@ import fs from "fs";
 import terminalLink from "terminal-link";
 import type { InstallTemplateArgs } from "./helpers";
 import { installTemplate } from "./helpers";
+import { templatesDir } from "./helpers/dir";
 
 export type InstallAppArgs = Omit<
   InstallTemplateArgs,
@@ -100,7 +101,7 @@ export async function createApp({
     });
     // copy readme for fullstack
     await fs.promises.copyFile(
-      path.join(__dirname, "..", "templates", "README-fullstack.md"),
+      path.join(templatesDir, "README-fullstack.md"),
       path.join(root, "README.md"),
     );
   } else {
diff --git a/e2e/utils.ts b/e2e/utils.ts
index e03ec73c7434d56f0d000e9cc54797fe53c20f90..d822327806e5143b913ddc1d27b8e1d9e0b76344 100644
--- a/e2e/utils.ts
+++ b/e2e/utils.ts
@@ -72,7 +72,14 @@ export async function runCreateLlama(
   externalPort: number,
   postInstallAction: TemplatePostInstallAction,
 ): Promise<CreateLlamaResult> {
-  const createLlama = path.join(__dirname, "..", "dist", "index.js");
+  const createLlama = path.join(
+    __dirname,
+    "..",
+    "output",
+    "package",
+    "dist",
+    "index.js",
+  );
 
   const name = [
     templateType,
diff --git a/helpers/dir.ts b/helpers/dir.ts
new file mode 100644
index 0000000000000000000000000000000000000000..08c2fe8fe84516f8dd7e059a8ee93213465ed10d
--- /dev/null
+++ b/helpers/dir.ts
@@ -0,0 +1,9 @@
+import path from "path";
+import { fileURLToPath } from "url";
+
+export const templatesDir = path.join(
+  fileURLToPath(import.meta.url),
+  "..",
+  "..",
+  "templates",
+);
diff --git a/helpers/index.ts b/helpers/index.ts
index 7415929d55cece9e3acf95e745921366ce1f87f9..f5467816f82e0a3fe78bf2d90f3cccea00bd7e6f 100644
--- a/helpers/index.ts
+++ b/helpers/index.ts
@@ -6,6 +6,7 @@ import path from "path";
 import { cyan } from "picocolors";
 
 import { COMMUNITY_OWNER, COMMUNITY_REPO } from "./constant";
+import { templatesDir } from "./dir";
 import { PackageManager } from "./get-pkg-manager";
 import { installLlamapackProject } from "./llama-pack";
 import { isHavingPoetryLockFile, tryPoetryRun } from "./poetry";
@@ -148,8 +149,7 @@ const copyContextData = async (
   // Copy folder
   if (dataSource?.type === "folder") {
     let srcPath =
-      dataSourceConfig.path ??
-      path.join(__dirname, "..", "templates", "components", "data");
+      dataSourceConfig.path ?? path.join(templatesDir, "components", "data");
     console.log(`\nCopying data to ${cyan(destPath)}\n`);
     await copy("**", destPath, {
       parents: true,
diff --git a/helpers/llama-pack.ts b/helpers/llama-pack.ts
index f70bc909aa206cc64fb396127761938578bf3b1d..adc0966afcec22a9797a367b819db72fe728d713 100644
--- a/helpers/llama-pack.ts
+++ b/helpers/llama-pack.ts
@@ -2,6 +2,7 @@ import fs from "fs/promises";
 import path from "path";
 import { LLAMA_HUB_FOLDER_PATH, LLAMA_PACK_CONFIG_PATH } from "./constant";
 import { copy } from "./copy";
+import { templatesDir } from "./dir";
 import { installPythonDependencies } from "./python";
 import { getRepoRawContent } from "./repo";
 import { InstallTemplateArgs } from "./types";
@@ -29,9 +30,8 @@ const copyLlamapackEmptyProject = async ({
   root,
 }: Pick<InstallTemplateArgs, "root">) => {
   const templatePath = path.join(
-    __dirname,
-    "..",
-    "templates/components/sample-projects/llamapack",
+    templatesDir,
+    "components/sample-projects/llamapack",
   );
   await copy("**", root, {
     parents: true,
@@ -42,7 +42,7 @@ const copyLlamapackEmptyProject = async ({
 const copyData = async ({
   root,
 }: Pick<InstallTemplateArgs, "root" | "llamapack">) => {
-  const dataPath = path.join(__dirname, "..", "templates/components/data");
+  const dataPath = path.join(templatesDir, "components/data");
   await copy("**", path.join(root, "data"), {
     parents: true,
     cwd: dataPath,
diff --git a/helpers/python.ts b/helpers/python.ts
index 7fa0064270f78819142a408d12821cb216bf691d..8b2ec6d90753c5bfee3a8452f7c0a108797a2c9c 100644
--- a/helpers/python.ts
+++ b/helpers/python.ts
@@ -4,6 +4,7 @@ import { cyan, red, yellow } from "picocolors";
 import { parse, stringify } from "smol-toml";
 import terminalLink from "terminal-link";
 import { copy } from "./copy";
+import { templatesDir } from "./dir";
 import { isPoetryAvailable, tryPoetryInstall } from "./poetry";
 import { InstallTemplateArgs, TemplateVectorDB } from "./types";
 
@@ -139,14 +140,7 @@ export const installPythonTemplate = async ({
   | "postInstallAction"
 >) => {
   console.log("\nInitializing Python project with template:", template, "\n");
-  const templatePath = path.join(
-    __dirname,
-    "..",
-    "templates",
-    "types",
-    template,
-    framework,
-  );
+  const templatePath = path.join(templatesDir, "types", template, framework);
   await copy("**", root, {
     parents: true,
     cwd: templatePath,
@@ -168,9 +162,7 @@ export const installPythonTemplate = async ({
   });
 
   if (engine === "context") {
-    const compPath = path.join(__dirname, "..", "templates", "components");
-
-    // Copy engine code
+    const compPath = path.join(templatesDir, "components");
     let vectorDbDirName = vectorDb ?? "none";
     const VectorDBPath = path.join(
       compPath,
diff --git a/helpers/typescript.ts b/helpers/typescript.ts
index 8b138c2117654acdc7ffbe44f85b21f917ad3d3f..cfadc67b1f96dd3e16c97fb5f938612067517168 100644
--- a/helpers/typescript.ts
+++ b/helpers/typescript.ts
@@ -5,6 +5,7 @@ import { bold, cyan } from "picocolors";
 import { version } from "../../core/package.json";
 import { copy } from "../helpers/copy";
 import { callPackageManager } from "../helpers/install";
+import { templatesDir } from "./dir";
 import { PackageManager } from "./get-pkg-manager";
 import { InstallTemplateArgs } from "./types";
 
@@ -70,14 +71,7 @@ export const installTSTemplate = async ({
    * Copy the template files to the target directory.
    */
   console.log("\nInitializing project with template:", template, "\n");
-  const templatePath = path.join(
-    __dirname,
-    "..",
-    "templates",
-    "types",
-    template,
-    framework,
-  );
+  const templatePath = path.join(templatesDir, "types", template, framework);
   const copySource = ["**"];
   if (!eslint) copySource.push("!eslintrc.json");
 
@@ -111,7 +105,7 @@ export const installTSTemplate = async ({
    * Copy the selected chat engine files to the target directory and reference it.
    */
   let relativeEngineDestPath;
-  const compPath = path.join(__dirname, "..", "templates", "components");
+  const compPath = path.join(templatesDir, "components");
   if (engine && (framework === "express" || framework === "nextjs")) {
     console.log("\nUsing chat engine:", engine, "\n");
 
diff --git a/package.json b/package.json
index 55580c3c1d7034f095416a069bfc4d16fa241762..4f6d64132b857e0428b2fcff5f974234760cc3ca 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
     "create-llama": "./dist/index.js"
   },
   "files": [
-    "dist",
+    "dist/index.js",
     "./templates"
   ],
   "scripts": {