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

  • SEARCH
  • Home
  • 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 8388277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:26:24+00:00 2026-06-09T18:26:24+00:00

I have a project laid out this way: lib/ bar.js curl.js src/ foo.js test/

  • 0

I have a project laid out this way:

  • lib/
    • bar.js
    • curl.js
  • src/
    • foo.js
  • test/
    • test.html

In my test/test.html file, I have the following

<script type="text/javascript" src="../lib/curl.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">

  curl(['../src/foo'], function (Foo) {
    console.log(Foo);
  });

</script>

This fails and the only work around I see is to include the following before I load curl.js:

<script>

  curl = {
    paths: {
      src: '../src'
    }
  };

</script>

So my first question is why do I have to setup paths this way if I just want to link to a single file in the src/ directory.

Assuming that first issue is fixed, my second problem is within src/foo.js. I want to have a dependency on lib/bar.js in that file, so I write the following:

define(['../lib/bar'], function (Bar) {
  return Bar;
});

Alas, this doesn’t work as curl.js is trying to load test/lib/bar.js and not lib/bar.js as I wish it would. If the only option is to specify a paths object for curl, is it possible to do that within the src/foo.js module or does it have to be all done in the test/test.html file?

  • 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-09T18:26:25+00:00Added an answer on June 9, 2026 at 6:26 pm

    So my first question is why do I have to setup paths this way if I just want to link to a single file in the src/ directory.

    Good question. This looks like it could be called a bug. We should probably fix this, but imho, it’s not a major one. Let me explain….

    curl.js is geared towards complex projects in which modules are bundled into “packages” — very similar in concept to CommonJS/NodeJS packages. In packages, it doesn’t make sense to use “../” to navigate out of a package and into another one. In fact, many of us believe that this should generate an error. curl.js unfortunately just silently fails in this case (that is definitely a bug imho).

    The bug you’re seeing may be that curl.js is applying the package-navigation logic when you’re not using packages. (Hm, sounding more like a bug to me all the time. 🙂 )

    So, generally, curl.js requires a configuration. The most essential piece of this config is baseUrl. baseUrl tells curl where the root of the application resides. In your case it’s “..” (you could also write it as “../” but curl will cut off the trailing “/” internally anyways.

    You don’t have to pre-configure curl with a global. You can also include the configuration the first time you call curl() like this.

    curl({ baseUrl: '..' }, ['src/foo'], function (Foo) {
        console.log(Foo);
    });
    

    I think that answers your second question, too. You can use baseUrl instead of configuring paths. However, paths will eventually come in handy once you start organizing your modules. For instance, paths can translate a messy path like this “lib/jquery-1.8.0/jquery.min.js” into just “jquery”.

    curl({ baseUrl: '..', paths: { "lib/jquery-1.8.0/jquery.min.js": "jquery" });
    

    I actually recommend packages over paths. As more people start writing CommonJS packages that can run in both node and the browsers, it could become unavoidable. Furthermore, we’re planning to build curl.js’s compile-to-javascript capabilities around packages.

    Hope I helped. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my solution laid out as follows src/Project1 src/Project2 src/Project... bin/*.{dll,exe} lib/Debug/*.dll lib/Release/*.dll
I have my project laid out like this: Project App1 App2 My static folder
I have a django project which is laid out like this... myproject apps media
I've got a Maven2 project with two submodules, laid out like this: parentproject |---war-file-project
I have a project that is laid out as follows: src/ java generated src/java
I have project with the following layout (Python 2.4.3) root +--- src +--- xyz
I have used the signalR chat app (as laid out in this tutorial http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/
I'm following the project structure as laid out by Zachary Voase , but I'm
I have project which includes external jar file in it, I followed this link
Suppose I have projects laid out like this. Project_Home A_Project B_Project C_Project D_Project Can

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.