Script fails in Webstorm but not from terminal

前端 未结 2 2003
耶瑟儿~
耶瑟儿~ 2020-12-30 06:07

I have a nodejs script that uses phantomjs-node to scrape a webpage. It works fine when I run from a terminal window, but not when I run from inside Webstorm via a run confi

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 06:43

    Webstorm does set a PATH variable, but it's different to the PATH variable your app gets when run in the terminal. My solution, a hack:

    1. Type node to get to the REPL
    2. Run process.env
    3. Copy the contents of the PATH value
    4. Add an environment variable to Webstorm called PATH that uses this value. It will overwrite the default PATH variable that Webstorm gives your app.

    Done!

提交回复
热议问题