I have this error in my Symfony 6.4 project since many months but I can't fix it.
Uncaught TypeError: The specifier “fos-router” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
In every JavaScript files which I use, I import FosJsRoutingBundle like this :
import Router from 'fos-router';
The library is found because I can display some Tree chart.
With a colleague, we tried with ./ , ../ and / whereas there no change. We create a file router.js to import FosJsRoutingBundle. This router.js
import Router from 'fos-router';
export default {Router};
The file router.js in the root of my javascript folder, in assets/javascript/router.js
Today FosJsRoutingBundle works on all pages except one. However, I import FosJsRoutingBundle in the same way in every page which need it.
test.js
We check the asset import in Twig, for example :
<script src="{{ asset('assets/javascript/flow/test.js') }}" type="module"></script>
<script src="{{ asset('assets/javascript/flow/test2.js') }}" type="module"></script>
<script src="{{ asset('assets/javascript/flow/index.js') }}" type="module"></script>
test2.js
let actionAccountButtons = document.getElementsByClassName("actionAccountButton");
console.log(actionAccountButtons);
The 2 test files work but index.js which contains an import to Fos display this error in the console : Uncaught TypeError: The specifier “fos-router” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
Do you know this error ?