# Importmap error @rails/request.js in production (heroku) disables Turbolinks

**URL:** <https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717>\
**Category:** General\
**Created:** [January 19, 2022, 11:42am UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717 "2022-01-19T11:42:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GuillaumeGrassiant](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/guillaumegrassiant/32/2461_2.png) [@GuillaumeGrassiant](https://discuss.hotwired.dev/u/GuillaumeGrassiant)\
**Post date:** [January 19, 2022, 11:42am UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717/1 "2022-01-19T11:42:21Z")

</div>

Hi everyone!  
Hope you are doing well.

I recently created a new project with Rails 7 and doing some Turbo\_stream and Turbo\_link as well as handling some requests via Stimulus before updating the UI.

For one of the Stimulus Controller, on change in a select tag, I make a request to my backend with `@rails/request.js`

The controller looks like this

```auto
import { Controller } from "@hotwired/stimulus";
import { get } from "@rails/request.js";

export default class extends Controller {
  static values = {
    url: String,
  };

  connect() {
    console.log("[Stimulus] successfully connected to the select_controller.js");
  }

  change(event) {
    const params = new URLSearchParams();
    params.append("target", event.target.dataset.id);
    params.append("selected_value", event.target.selectedOptions[0].text);

    get(`${this.urlValue}?${params}`, {
      responseKind: "turbo-stream"
    });
  }
}

```

I followed the instruction [here](https://github.com/rails/requestjs-rails) to install `@rails/request.js` in my project.

Everything is fine locally (Turbolinks, Actioncable etc.) but when I deploy to Heroku (after provisioning a Redis instance) I get the following error:

`Uncaught TypeError: Failed to resolve module specifier "@rails/request.js". Relative references must start with either "/", "./", or "../".`

I understand as per the [documentation](https://github.com/rails/importmap-rails#expected-errors-from-using-the-es-module-shim) that it has no user-facing consequences.

The main problem with that is Turbo is not working properly (clicking on a link in the pagination for example or submitting a form reloads the entire page).

I saw in the Heroku logs the following: `Importmap skipped missing path: rails-requestjs`.

I ran `bin/importmap pin @rails/requestjs` but funny enough if I run `./bin/importmap json` locally, `@rails/request.js` is in the imports but the same command on Heroku returns:

```auto
 WARN -- : Importmap skipped missing path: rails-requestjs
{
  "imports": {
     [...]
  }
}

```

If I remove the gem and the parts of code related to `@rails/requestjs`, push to heroku again, Turbo\_frames and link work correctly (without reloading the page).

I guess it’s a setting I haven’t handled properly when deploying but I am not sure exactly what to do. If you have any idea that would be awesome!

Have a nice day.

---

<div class="post-metadata">

**Author:** ![ghiculescu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/ghiculescu/32/1328_2.png) [@ghiculescu](https://discuss.hotwired.dev/u/ghiculescu)\
**Post date:** [January 19, 2022, 8:01pm UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717/2 "2022-01-19T20:01:00Z")

</div>

Looks like you aren’t the only person to notice this. See [The path is not recognized when using importmap · Issue #5 · rails/requestjs-rails · GitHub](https://github.com/rails/requestjs-rails/issues/5)

---

<div class="post-metadata">

**Author:** ![GuillaumeGrassiant](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/guillaumegrassiant/32/2461_2.png) [@GuillaumeGrassiant](https://discuss.hotwired.dev/u/GuillaumeGrassiant)\
**Post date:** [January 19, 2022, 8:02pm UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717/3 "2022-01-19T20:02:07Z")

</div>

Oh wow! Thanks a lot, I subscribed to the issue.  
Have a great day.

---

<div class="post-metadata">

**Author:** ![GuillaumeGrassiant](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/guillaumegrassiant/32/2461_2.png) [@GuillaumeGrassiant](https://discuss.hotwired.dev/u/GuillaumeGrassiant)\
**Post date:** [January 21, 2022, 12:48pm UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717/4 "2022-01-21T12:48:23Z")

</div>

Maintainer will look into it but as a temporary fix, as suggested in the Github issue thread:

- removing the gem
- running `bundle install`
- pinning manually `pin "@rails/request.js", to: "https://ga.jspm.io/npm:@rails/request.js@0.0.6/src/index.js"` to `importamp.rb`
- redeploying

Solves the problem

---

<div class="post-metadata">

**Author:** ![GuillaumeGrassiant](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/guillaumegrassiant/32/2461_2.png) [@GuillaumeGrassiant](https://discuss.hotwired.dev/u/GuillaumeGrassiant)\
**Post date:** [January 24, 2022, 4:17pm UTC](https://discuss.hotwired.dev/t/importmap-error-rails-request-js-in-production-heroku-disables-turbolinks/3717/5 "2022-01-24T16:17:41Z")

</div>

Now fixed with this PR:

> <https://github.com/rails/requestjs-rails/pull/6>
>
> fix: #5 
> 
> \- Bundled with this Gem is \`requestjs.js\`, not \`request.js\`.
> - …https://github.com/rails/requestjs-rails/blob/main/app/assets/javascripts/requestjs.js
> \- Did not work \`to: "rails-requestjs"\`, but it worked \`to: "requestjs.js"\`
