In my project I use
import defaultExport from package-name/module-name.
When loading the project to Snack, I get a message suggesting that I add package-name/module-name as a dependency to my package.json, although it already includes a package-name dependency.
If I refuse, playing the app results with an exception.
If I agree, the app plays successfully.
As far as I understand, my import syntax and package.json syntax are valid. Moreover, adding a a package-name/module_name as a dependency in package.json is not valid.
What’s going in there?
What you’re seeing is a consequence of Snack bundling each of your project separately and stitching them together on the phone rather than bundling your entire project up on your local machine. This let’s snack run fast, but results in the surprising behaviour you’re seeing.
A bit more detail here: https://github.com/expo/snack-sdk#differences-between-dependencies-in-snack-and-npm
Often you’ll have the choice of doing
import module from 'package/module' (where the relationship is defined in the filesystem). The former will allow your snacks to work with needing the additional dependency.
OK, thanks for the reply!
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.