Unable to locate rollup using Yarn?

I'm facing an issue while attempting to construct lumo (a Clojurescript REPL) from source within a Debian chroot environment. The error I encounter is as follows:

Building production bundle...
Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/cljs.js
Circular dependency: src/js/cli.js -> src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cli.js
Circular dependency: src/js/repl.js -> src/js/socketRepl.js -> src/js/repl.js
Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cljs.js
internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module 'rollup'
Require stack:
- /root/tmp/lumo-1.10.1/scripts/bundleForeign.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/root/tmp/lumo-1.10.1/scripts/bundleForeign.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/root/tmp/lumo-1.10.1/scripts/bundleForeign.js' ]
}

I've attempted yarn add rollup, npm install rollup, and npm install -g rollup, with no success.

Regrettably, my understanding of this build system isn't sufficient to determine the next troubleshooting step.

Any suggestions?

Provided below are the build scripts: https://gist.github.com/cellularmitosis/df87e0c962e184b8bd29c8a3f07f3db4

EDIT: Here is what's in bundleForeign.js:

const rollup = require('rollup').rollup;
const resolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const commonjs = require('rollup-plugin-commonjs');

rollup({
  input: 'node_modules/google-closure-compiler-js/compile.js',
  plugins: [
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    resolve({
      mainFields: ['module', 'main', 'jsnext:main'],
    }),
    commonjs(),
  ],
})
  .then(bundle => {
    bundle.write({
      format: 'cjs',
      file: 'target/google-closure-compiler-js.js',
      strict: false,
    });
  })
  .catch(console.error);

EDIT2: Is this potentially just a node problem?

I went ahead and created /tmp/foo.js:

const rollup = require('rollup').rollup;

Then executed cd /tmp && node foo.js, resulting in the same error:

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module 'rollup'
Require stack:
- /tmp/foo.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/tmp/foo.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/tmp/foo.js' ]
}

I also tried npm install -g rollup but that didn't make a difference. Perhaps node isn't searching for global modules correctly?

Answer №1

Wow, what a silly mistake I made!

$ export NODE_PATH=/usr/local/node-v13.5.0-linux-x64/lib/node_modules/
$ node bar.js
$ echo $?
$ 0

All this time, all I had to do was set the NODE_PATH variable.

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

Different Ways to Incorporate Event Tracking into a JavaScript Alert

My website is quite simple, with just 4 hyperlinks. I'm conducting an experiment on bounce rates and trying to implement an event in a JavaScript alert. The goal is for the event to register when the user clicks "ok" on the alert, thus reducing the bo ...

When hovering over, make sure not to conceal the item

When I hover over the blue table, two red buttons named del-row-td and del-column-td appear. However, they disappear when I move my mouse away from the table. https://i.sstatic.net/WiWRU.png I want to prevent these red buttons from disappearing when I ho ...

Jest test failing due to issues with a stateful React component containing an asynchronous function

I'm currently going through a Jest testing tutorial on Pluralsight that can be found here. Even though I have written the code exactly like the author, my test is not passing for some reason. Link to my Pull request on the author's repo: https:/ ...

Having trouble with a Three.JS/WebGL 3D object not loading in Firefox?

After creating a 3D Object using Three.js examples, I noticed that it works perfectly in Chrome and IE 11, but for some reason, it's not loading on Firefox. I am currently using the latest version of Firefox (FF 27.0). When I tested the code on Firef ...

Regular Expression - Invalid character detected in output

I'm currently in the process of developing a function to verify if a field is deemed acceptable based on a specific character set. In case it doesn't meet the criteria, I aim to determine and communicate which characters are not permitted. While ...

Custom div element obstructs information window on map due to lack of auto panning feature

I created a unique div that is absolutely positioned on a Google Map. You can view the image below to see it. My issue is that the info window is being covered by this custom div element, as demonstrated in the picture. https://i.stack.imgur.com/1TgyQ.jpg ...

Ways to identify if a JavaScript file has already been packed

Hello everyone! I'm currently working on a Windows application using C# that minifies CSS files and packs JS files in bulk. I've come across a challenge where if the user selects a JS file that has already been packed, it will actually increase t ...

Angular: Issue with click() event not functioning properly once dynamic HTML is rendered

There are a few HTML elements being loaded from the server side, and an Angular click() event is also included. However, the event is not firing after the elements are rendered. It is understood that the DOM needs to be notified, but this cannot be done. ...

Is there a way to efficiently modify the positions of numerous markers on Google Maps while utilizing PhoneGap?

Hey there, I'm new to this and I have a service for tracking multiple cars. I'm using a timer to receive their locations, but I'm having trouble figuring out how to update the old marker with the new value. I've tried deleting all the m ...

Using React to Grab Initial List with AJAX Request

Recently, I began delving into React and came across a compelling example in the official documentation on how to initially load data via AJAX: var LatestUserGists = React.createClass({ getInitialState: function() { return { userna ...

Employ node's gm library in combination with promises and buffers

Using gm with Bluebird has been a bit tricky for me. Initially, I tried this approach: var gm = require('gm'); var bluebird = require('bluebird'); gm = bluebird.promisifyAll(gm); However, when attempting to execute the following code: ...

Display/Conceal the UL subelement when selected

I've been struggling to toggle the visibility of some ul checkboxes when their parent is clicked. Despite my best efforts, I just can't seem to make it work! Could someone lend a hand in getting this functionality working? Essentially, I need th ...

How do you prevent overlapping divs from being clickable in order to access content below?

Currently, I am utilizing a JPG overlay with decreased opacity for a particular effect. However, I am interested in keeping it solely as an aesthetic effect and making the content beneath that division clickable. Do you think this is achievable? Thanks! I ...

Launch a nearby hyperlink in a separate tab

I am currently facing an issue where all the URLs in a Text get linked as Hyperlinks. However, when a user types www., the browser interprets it as a local URL and associates the link with the application's URL. Does anyone know how to open a local U ...

Modify the size of images retrieved from the Twitch API

I have a request to the Twitch API to retrieve a list of top games and show their box art, but I'm facing an issue where the image will only display if I adjust the width and height values in the provided link. Is there a way to modify these values wi ...

Troubleshooting: Issue with Bootstrap carousel not displaying thumbnails properly after recent modification

For the product image gallery, I have implemented this code but it seems to be having some issues. The thumbnail images are not moving the main images correctly. Can someone help me identify and solve the problem? ...

Is it possible to customize the MongoDB Collection before loading the web application by fetching data asynchronously using Promises?

I am currently working with MongoDB and NodeJS, trying to preload my Collection customers every time the site is loaded. The process involves emptying the collection, populating it with empty Documents, and then replacing them with real data fetched from a ...

Using only JavaScript, apply attributes to the <html> tag

I am trying to assign two attributes, dir: rtl and lang: ar, to the <html> tag. dir: rtl lang: ar My attempts so far include: document.documentElement.outerHTML.setAttribute("dir", "rtl"); document.documentElement.outerHTML.setAttribute(" ...

What is the best way to sort out the <li> elements within a <ul> that has a specific id

<ul class="apple" id="A"> <li> <li> ..... ...... ...... </ul> <ul class="apple" id="C"> <li> <li> ...

How can I transform my JavaScript code into ReactJS?

Is it feasible to transform certain JavaScript code into a ReactJS component? Could anyone lend me a hand with this, please? ...