I didn't see an npm-install command anywhere in the tutorial you linked.
In your pluggable widget code directory, you should have a node-modules folder where npm packages are installed. in there, if you run an npm-install for that package, it should be available for import in your custom widget. For the project as a whole for use in JS actions, you can check this out which follows the same idea as long as the library is linked/imported into the right place:
https://docs.mendix.com/howto/extensibility/create-native-javascript-action/#auto-linking