Closed bijanmmarkes closed 6 years ago
I am working on a project which is using componentjs
Be aware, componentjs is deprecated since 2015
When trying to require a module in the node_modules folder such as require("nodemailer"); It cannot find it
nodemailer is not a compatible with component
There are no component dependencies which allow for mail.
componentjs is a build tool for frontend modules. Mail related modules require a server.
How do you require a node_module without having to create a component out of it? any ideas?
Not at all, if you're using componentjs. Just use Node.js
The problem is the structure of component is it doesn't allow you to require node_modules from the server as it is trying to look for a component. I know nodemailer would not work with component but it seems to override the require command completely which is how you require server-side node_modules. How do you require non-components using node.js and use them on the front-end when component is present in the project? How would i require nodemailer using the "require" command when it tries to look for a component?
The problem is the structure of component is it doesn't allow you to require node_modules from the server as it is trying to look for a component.
Of course, as I said, component is a package manager and build to tool (bundler) for the frontend. You won't be able to require a module which doesn't have nor a component.json or some special properties in the package.json and that is by design!
I know nodemailer would not work with component but it seems to override the require command completely which is how you require server-side node_modules.
Not exactly, it just provides an implementation of require, because browsers don't have require
implemented.
How do you require non-components using node.js and use them on the front-end when component is present in the project?
component.json
or these properties to the module.How would i require nodemailer using the "require" command when it tries to look for a component?
Ah, I think I got it. So you have already component in usage. But i still don't understand how you want to use nodemailer in the browser, this doesn't make sense and is just impossible, see https://stackoverflow.com/questions/37630543/can-i-use-nodemailer-in-browser
Anyway if you want to load a module which is not compatible with component you basically need another bundler. Some bundler polluting the global scope with require
so you need to take care that they are bundling their modules isolated, for component see https://github.com/componentjs/guide/blob/master/creating-components/standalone-umd-builds.md
But this sounds like a really ugly hack. I recommend you to switch from component to webpack or some other maintained bundler.
I am working on a project which is using componentjs, When trying to require a module in the node_modules folder such as require("nodemailer"); It cannot find it. There are no component dependencies which allow for mail. How do you require a node_module without having to create a component out of it? any ideas?