Is there a way to debug grunt serve in a virtualenv in Pycharm?

Answered

I normally run grunt serve in a virtual environment by running the following two commands:

source ./env/bin/activate
grunt serve

Is there a way to configure the grunt tool in Pycharm to use the virtualenv?

I assume it's done in the window shown in the screenshot below but I cannot figure out how to get it to work.  

This is the error I get when I try to start grunt serve using this tool.  It is the exact same error I get if I try to start grunt serve and I have not activated the virtual environment.  

/usr/local/bin/node --debug-brk=51383 --expose_debug_as=v8debug /usr/local/lib/node_modules/grunt-cli/bin/grunt --gruntfile /Users/tcl/_myproject/workspace/myproject_web/Gruntfile.js serve
Debugger listening on [::]:51383
Running "bgShell:runDjango" (bgShell) task

    Running "watch" task
    Waiting...>> Traceback (most recent call last):
    >>   File "myproject_web/manage.py", line 13, in <module>
    >>     from configurations.management import execute_from_command_line
    >> ImportError: No module named configurations.management
    >> Error: Command failed: python myproject_web/manage.py runserver 0.0.0.0:7000

This is the configuration for the environment

I am doing all of this on a Mac (OS X).  

EDIT:

I've also tried creating a new virtaulenv from PyCharm using PyCharm->preferences->[my_project]->Project Interpreter->[gear_icon]->Create Virtual Env

I then set the project environment to this environment and tried to start the grunt server but got the same error:

/usr/local/bin/node --debug-brk=51694 --expose_debug_as=v8debug /usr/local/lib/node_modules/grunt-cli/bin/grunt --gruntfile /Users/tcl/_my_project/workspace/my_project_web/Gruntfile.js serve
Debugger listening on [::]:51694
Running "bgShell:runDjango" (bgShell) task

Running "watch" task
Waiting...>> Traceback (most recent call last):
>>   File "my_project_web/manage.py", line 13, in <module>
>>     from configurations.management import execute_from_command_line
>> ImportError: No module named configurations.management
>> Error: Command failed: python my_project_web/manage.py runserver 0.0.0.0:7000

It seems the virtual environment isn't being activated. How do I activate the virtualenv for grunt to work (I've tried activating it from a terminal window but PyCharm isn't "in" that activated version).

 

 

 

0
1 comment

Hi Jgresh! Unfortunately, it can't be done from the PyCharm UI at the moment. But I think you can try to do it this way: https://stackoverflow.com/questions/21943115/starting-a-django-virtual-environment-in-grunt

0

Please sign in to leave a comment.