Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Cannot find node module in rails stimulus controller

I have a problem with importing an npm package that I have created into my rails application.

I'm unsure if the problem is in the way I have created the node package or with the rails app.

The package is very simple -> https://www.npmjs.com/package/test-release-stuff

Now when I'm trying to import it into rails (I install it vie yarn and then see it's in the node modules) and I try to import it into my stimulus controller it tells me that it can't find the module. The error literally says:

Error: Cannot find module 'test-release'stuff'

How I'm importing the module?

I'm doing import foo from 'test-release-stuff'

One thing to note is that when I tried that in a simple react todo app it was imported without any issues.

I have a feeling that it might be something with the webpacker config in my rails app (below is the config) or that it might be something with the node packaga packgage.json file, there might be something incorrect there.

const { webpackConfig, merge } = require('@rails/webpacker');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const plugins = [];

if (process.env.ANALYZE === 'true') {
  plugins.push(new BundleAnalyzerPlugin());
}

const customConfig = {
  resolve: {
    extensions: ['.css'],
  },
  plugins: plugins,
};

module.exports = merge(webpackConfig, customConfig);

then in the production/development/test files I have something like this:

process.env.NODE_ENV = process.env.NODE_ENV || 'production';

const webpackConfig = require('./base');

module.exports = webpackConfig;

It's a rails 6 project.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Turns out it was neither rails app fault or the node package fault.

I'm running the project inside the container. Although I installed once the previous version of that node package, when updating it, the changes were not properly reflected inside the container - I assume at some point the actual yarn command was not firing or that there was some caching involved.

After properly bringing the containers down, running docker-compose build and docker-compose up the changes were reflected and I can use the node package.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!