RequireJS has an unbreakable reliance on the library

For my Angular + Require project, I encountered an issue while trying to package the application with r.js using:

node r.js -o app.build.config.js

Despite everything working fine, the library files were not found on the specified path. Instead, the dependencies were being searched for relative to the folder I set as a target.

({
    appDir: "C:/dev/etc/",
    baseUrl: "javascript/core/",
    dir: "app-build/",
    modules: [
        {
            name: "application",
            out: "app.js"
        }
    ],
    findNestedDependencies: true
})

Answer №1

To avoid duplicating values in a separate configuration file and share the same setup used by your runtime code to locate libraries like Angular, you can utilize the mainConfigFile option:

When you want the build process to refer to the main JS file configuration directly, you can set the "mainConfigFile" property to point to that specific file. Any configuration found within the first requirejs({}), require({}), requirejs.config({}), or require.config({}) call in that file will be applied.

Your build configuration may resemble the following example:

({
    appDir: "C:/dev/etc/",
    baseUrl: "javascript/core/",
    mainConfigFile: 'c:/dev/etc/js/config.js', // specify your file name here
    dir: "app-build/",
    modules: [
        {
            name: "application",
            out: "app.js"
        }
    ],
    findNestedDependencies: true
})

I faced a similar problem which was resolved by adding the mainConfigFile line. Previously, without it, the r.js optimizer would throw an error like the following:

Error: ENOENT, no such file or directory '/some/path/app-build/jquery.js' In module tree: application

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The resizing of the window does not occur when a scrollbar is automatically added in IE11

I encountered an issue with my Angular project where the view resizes properly in Chrome and Firefox, but not in IE 11. When the scrollbar appears, some components get covered by the scrollbar. Here is the CSS for the menu: #menu-principal .navbar-lower ...

An uncomplicated broadcasting and receiving method utilizing an event emitter

This code is from chapter 3, example 11 of the book Node.JS in Action, found on page 52. var events = require('events'); var net = require('net'); var channel = new events.EventEmitter(); channel.clients = {}; channel.subscriptions = ...

Discover a class located following a specific element even when they are not directly related

There is a group of elements all with the class month. Some of them also have the class cal, while only one has the class today. The goal is to locate the first element with the class cal, but only after finding the element with the class today. The chall ...

Issues with websockets functionality have been reported specifically in Firefox when trying to connect to multiple

I am currently working on a websocket client-server application. The client code is as follows: const HOST = "wss://localhost:8000"; const SUB_PROTOCOL= "sub-protocol"; var websocket = new WebSocket(HOST, SUB_PROTOCOL); websocket.onopen = function(ev ...

The PHP script is not being activated by AJAX

I am completely baffled by the situation at hand. Sometimes, I open a different browser to test my changes and it works as expected. But then, when I try again, it fails. It's driving me crazy. On syllableapp.com, I set up a MySQL database that I can ...

Issue with highcharts and vue.js: creating a unique chart for displaying measurements

Currently, I am integrating Highcharts and Vue.js simultaneously while incorporating multiple charts on my webpage. As of now, I have successfully displayed data on all the charts without encountering any issues. However, my goal is to assign a special tit ...

Trigger Element Upon Click

Forgive me in advance for the lack of quality in this question, but I'll proceed anyway: All I want is for an element to slide open when clicked with a mouse! That's all! More specifically, I am looking for a single menu item that, upon clickin ...

Organizing Angular Material Styles using Namespacing

In an attempt to develop reusable components with Angular 1.4.3 and Angular-Material 1.0.5, the goal is to seamlessly integrate these components across various applications. However, a challenge arises as the Angular Material CSS contains styling rules th ...

Angular Js: Displaying JSON Object with Multiple Nested Layers

Looking for a way to display a menu using Angular and JSON object that utilizes ul and li. Trying to achieve this using ng-repeat, but encountering challenges when dealing with deeply nested objects. Here's the HTML code: <ul> <li ng-rep ...

Troubleshooting the date axis issue with AngularJs ui-chart

I have been utilizing the ui-chart directive for jqplot to display a line chart in my AngularJS application. Strangely, the date xaxis is not appearing on the chart. The data for the chart is fetched from an API call and I am populating the chart data usin ...

The functionality of passing POST variables to the model seems to be malfunctioning in PHP CodeIgniter when attempting to use the

I attempted the code snippet below: function doAjax() { var sList = ""; $('input[type=checkbox]').each(function () { var sThisVal = (this.checked ? "1" : "0"); ...

How can we determine in JavaScript when AngularJS has completed compiling its view?

I am having an issue where I need to use a JQ plugin on elements that are defined in an AngularJS View template. Typically, I would call the plugin like this: $(function() { $( "#selectable" ).selectable(); }); However, this approach is not workin ...

Is npm create-react-app giving you trouble?

When attempting to create a React app using the command npm create-react-app appname, the tool would just return me to the same line to input more code. I also gave npx a try, but encountered some errors in the process. See this screenshot for reference: ...

Utilizing Cookies within an HTML Page

My current code is functioning perfectly, accurately calculating the yearly income based on the input "textmoney." I have a link to a more advanced calculator for a precise prediction. My goal is to find a way for the website to retain the data input from ...

Error in Express Post Request: Headers cannot be modified after being sent to the client

I am a beginner in Node.js and I am facing some challenges while working on an app for learning purposes. I encountered the following issue: Error: Can't render headers after they are sent to the client. I am unsure of how to resolve it. C:\Us ...

How can the threejs Box3().getSize() method be effectively utilized?

There seems to be a discrepancy in the proper usage of the Box3() getSize() method, as discussed on various platforms including stackoverflow. const geometry = new THREE.BoxGeometry( 10, 10, 10 ); const material = new THREE.MeshBasicMaterial( {color: 0x00f ...

How should an iterable be sorted in React?

Let's break down the scenario using pseudo code: {this.props.myIterable.map((iterable) => { return ( <div>iterable.somevalue</div> ) }).sort((a,b) => {return b - a}) To clarify, I am iterating over certain props and displaying ...

Encountering a POST 504 error while attempting to proxy an Angular application to a Node server

error message: Failed to connect to http://localhost:4200/api/user/login with a 504 Gateway Timeout error. Encountered this issue while attempting to set up a login feature in my Angular application and establish communication with the Express backend. Th ...

MinifyJS - optimize all .js files within a directory

Seeking assistance to finalize my build process: I am currently transpiling es6 > es5 using babel. Once that is complete, I aim to minify all my .js files recursively with uglifyJS solely using NPM scripts (no grunt or gulp). My Requirements; Convert ...

How can I retrieve elements i from each array in HandlebarsJS and then access element j, and so on?

Given a JSON like this: { "network": [ { "name": [ "John", "Jill", "June" ] }, { "town": [ "London", "Paris", "Tokyo" ] }, { "age" : [ "35", "24", "14" ] } ] } Unfortunately, my data is in this format and I have to work w ...