Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:13:37+00:00 2026-06-18T07:13:37+00:00

I have a Titanium project which uses the CommonJS module style. However the code

  • 0

I have a Titanium project which uses the CommonJS module style. However the code uses absolute paths so that when it builds the absolute path is sandboxed to the application directory.

var foo = require("/lib/module");

I want to run some tests on the command line and have jasmine-node working. However when a test executes a module the module will have the above absolute paths in their require statements.

Is there a way to isolate (maybe chroot) node to resolve absolute require paths to a specific directory? If so how?

-- RepositoryRoot/
   |- app/
   |  \- Resources/
   |     |- app.js  # Has require("/lib/module1.js")
   |     \- lib/
   |        |- module1.js # Has require("/lib/module2.js")
   |        \- module2.js
   \- tests/
      \- module1.spec.js # Has require("../app/Resources/lib/module1")
                         # Or require("/lib/module1")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:13:39+00:00Added an answer on June 18, 2026 at 7:13 am

    After finding a solution here is what I learned: The short answer to the exact above question is you can’t do that. Node reads absolute paths as absolute paths. So the answer in short was to change my paths from absolute to pseudo-absolute (relative) paths. Here is a quote from this blog post that sheds some light:

    the Titanium implementation of CommonJS require() is buggy and
    doesn’t correctly support relative paths. This represents a major
    problem when trying to integrate jasmine-node test runners in projects
    with even minimally complex directory trees.

    A possible solution to the issue is to not use relative paths in
    require() in Titanium (but you are free to use them in your jasmine
    specs run through node). Instead of relative paths we need to use full
    paths with Resources as the root directory.

    This is accomplished by setting the NODE_PATH environment variable prior to running any node commands. That way a path such as `require(“module/path”) is resolved by node and titanium.

    There are a few caveats. Some module force the need for absolute paths. In this case one needs proxyquire to mock out the absolute paths as long as there are not any circular dependancies this will work. Also since node does not have Titanium API’s you also have to include the mockti package to mock out the Titanium API. Use this in your spec_helper.js:

    global.Ti = require("mockti");
    

    and

    proxyquire = require("proxyquire");
    var myModule = proxyquire("relative/path/to/MyModule", {
        "/absolute/path/to/some/module": require("absolute/path/to/some/module")
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in a Mobile project (using Titanium Studio), in which i have
I have a new project which is an iPhone application. for that I have
I have created titanium mobile module project and copied .zip file to /lib folder
I have a Titanium Mobile project for iOS devices and would like to make
I have a JSON that contains the following: {p1:{debris:{titanium:0,silicum:0}},p2:{debris:{titanium:0,silicum:0}}... I declare the data using
I'm currently using JavaScript (CommonJS) in Titanium Studio and have a question about prototyping.
I have this Xcode project that I use for building an App Store app
I have been using Titanium for an Android application that does some microblogging through
I have created an application using Titanium Appcelerator in which I am using a
I have created iOS module in Titanium. This module includes my own framework written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.