You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone, I was trying to use Cropper.js V2 (2.0.0-rc.2) in my Symfony 7 project, and I found that the documentation on the website is not very detailed. To install Cropper.js, I use:
npm install cropperjs@next
Then, I go to the page where I need the Cropper and add the following in the <script> tag:
import Cropper from 'cropperjs';
(as per the documentation). However, this throws an error:
Uncaught SyntaxError: Cannot use import statement outside a module (at 77?tab=settings:564:5)
This happens because my <script> tag is missing the attribute type="module". If I add that attribute, I get a different error:
Uncaught TypeError: Failed to resolve module specifier "cropperjs". Relative references must start with either "/", "./", or "../".
Additionally, my Cropper.js file is located in the node_modules directory. If I try to import it directly from the "layout" page (the default page for all others) using:
<script src="../../node_modules/cropperjs/dist/cropper.js"></script>
(Which I verified to be the correct path), I get this console error:
Uncaught SyntaxError: Unexpected token '<' (at cropper.js:1:1)
I have no idea how to fix this or how I should correctly import and use Cropper.js.
(In my project I have the Web Pack encore).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone, I was trying to use Cropper.js V2 (2.0.0-rc.2) in my Symfony 7 project, and I found that the documentation on the website is not very detailed. To install Cropper.js, I use:
npm install cropperjs@next
Then, I go to the page where I need the Cropper and add the following in the <script> tag:
import Cropper from 'cropperjs';
(as per the documentation). However, this throws an error:
Uncaught SyntaxError: Cannot use import statement outside a module (at 77?tab=settings:564:5)
This happens because my <script> tag is missing the attribute type="module". If I add that attribute, I get a different error:
Uncaught TypeError: Failed to resolve module specifier "cropperjs". Relative references must start with either "/", "./", or "../".
Additionally, my Cropper.js file is located in the node_modules directory. If I try to import it directly from the "layout" page (the default page for all others) using:
<script src="../../node_modules/cropperjs/dist/cropper.js"></script>
(Which I verified to be the correct path), I get this console error:
Uncaught SyntaxError: Unexpected token '<' (at cropper.js:1:1)
I have no idea how to fix this or how I should correctly import and use Cropper.js.
(In my project I have the Web Pack encore).
Beta Was this translation helpful? Give feedback.
All reactions