Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda