Controllers/index.js 에서 require 시 경로 문제

안녕하세요!
Titanium 공부중에 궁금한 점이 있습니다.

controllers/index.js 에서
require를 이용하여,
var library = require(‘lib/library’); 로 로드를 했는데요… 경로를 도무지 못찾겠습니다. ㅠ

…/lib
…/…/lib
./lib
다 해봤는데 안되네요. 고수님들의 답변이 절실합니다 !!

디렉토리 구조는 아래와 같습니다.
{project} /
  app/
    assets/
    controllers/
         index.js
    lib/
         library.js

[ERROR] : TiExceptionHandler: (main) [386,386] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,386] - In ti:/module.js:280,9
[ERROR] : TiExceptionHandler: (main) [0,386] - Message: Uncaught Error: Requested module not found: …/…/lib/library
[ERROR] : TiExceptionHandler: (main) [0,386] - Source: throw new Error("Requested module not found: " + request);
[INFO] : I/dalvikvm-heap: Grow heap (frag case) to 17.791MB for 629776-byte allocation
[ERROR] : V8Exception: Exception occurred at ti:/module.js:280:

var library = require(“library”);

1개의 좋아요

lib외 assets 폴더 안에 있는 내용은 alloy 컴파일 과정에서 Resources 폴더로 옮겨집니다.
그렇기 때문에
희두님이 말씀하신 코드처럼 경로 없이 가능합니다.

제사한 사항은 아래 링크를 참조하세요. Titanium Documents의 가이드 문서들은 정말 좋아요. 꼭 보기길 권장합니다.
http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Concepts-section-34636240_AlloyConcepts-ConventionoverConfiguration

와우! 친절하신 설명 정말 감사합니다. 도움이 많이 되었습니다.