Yarn Berry - Run a Node Script Directly

☆樱花仙子☆ 提交于 2021-02-11 12:01:28

问题


Yarn berry (v2) got rid of node_modules (which I really love) by introducing pnp. However, scripts executed by node directly don't understand pnp modules, so you have to use yarn to run such a script.

Is there some way (e.g. a require script like ts-node provides) so that I can still use node to launch my script that requires pnp modules?

Background is that I want to configure the Mocha Sidebar extension for VS Code to support pnp. I can add configure node options there and specify files that are required automatically.


回答1:


That's the (undocumented) solution:

require(".pnp.js").setup();


来源:https://stackoverflow.com/questions/61475926/yarn-berry-run-a-node-script-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!