-
Notifications
You must be signed in to change notification settings - Fork 43
import from global node_modules at NODE_PATH with --input-type=module
#534
Comments
Yes, node certainly supports that syntax. However, ESM doesn’t support NODE_PATH - which has been discouraged (by the community, if not node itself) for many years. You can import things installed locally, in node_modules, or relative files. |
Perhaps a |
@cmonacaps a workaround to avoid needing to use |
Ok Thanks for the update and link to the workaround. I think, for what I was trying to achieve, it's just as well to create fewer and better-developed scripts which are themselves packaged global installs, with their dependencies stated and installed as such, using the It might have been easier to get there from the way I was headed, but otoh I notice when using nodejs that I never see the global/host-configuration dependency conflicts I've seen with other common interpreted languages that do support this kind of workflow. I'm just speculating that this is the reason this approach is, per your link for example, discouraged. That there is a global |
Hi,
I found that while
--input-type=module
import * as R from 'ramda'
orimport R from 'ramda'
NODE_PATH
set, I think, properlyI get an error,
ERR_MODULE_NOT_FOUND
when the script piped intonode
tries to import.I'm a bit puzzled what the source of the problem is, it seems to center on resolving esm modules but also perhaps the env plays a part, because from the development directory of the
node-esm
project, it works ok to runnode index.js /usr/local/bin/useless_ramda_script
, perhaps in that case it's using theramda
installed in that package rather than the global one. There are a lot of experimental parameters to influence the import behavior innode
, and, there are a lot of ways to spawn the script fromnode-esm
, I tried a few which are still present in the code in unused subroutinesmakeFutureSpawnScript
andmakeFutureVm
as well as the one that seemed to work best so far,makeFutureSpawnPipe
.See full source code at https://github.com/cmonacaps/node-esm
Asides, does node support
import * as X from 'package'
? Am I going to have to havenode-esm
run babel on the script to get this working?The text was updated successfully, but these errors were encountered: