2016-01-20 28 views
1

我正在使用django-pipeline-browserify橋接django-pipeline和browserify。 但是,如果沒有以下錯誤,我無法收集靜態數據。 我能夠通過複製錯誤消息中顯示的命令來手動編譯js文件。因此,我不知道我在這裏做錯了什麼。在django collectstatic期間使用browserify的FileNotFoundError

You have requested to collect static files at the destination 
location as specified in your settings: 

    /var/www/anime/static 

This will overwrite existing files! 
Are you sure you want to do this? 

Type 'yes' to continue, or 'no' to cancel: yes 

matching file: animelist/css/style.css 
Post-processed 'animelist/css/animelist_css.css' as 'animelist/css/animelist_css.css' 

matching file: animelist/js/bower_components/jquery/dist/jquery.min.js 

matching file: animelist/js/bower_components/react/react-with-addons.js 

matching file: animelist/js/app.browserify.js 

command: /usr/bin/env browserify /var/www/anime/static/animelist/js/app.browserify.js > /var/www/anime/static/animelist/js/app.browserify.browserified.js 
Traceback (most recent call last): 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/compilers/__init__.py", line 120, in execute_command 
stderr=subprocess.PIPE) 
    File "/usr/lib64/python3.4/subprocess.py", line 858, in __init__ 
restore_signals, start_new_session) 
    File "/usr/lib64/python3.4/subprocess.py", line 1456, in _execute_child 
raise child_exception_type(errno_num, err_msg) 
FileNotFoundError: [Errno 2] No such file or directory: ' ' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
execute_from_command_line(sys.argv) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
utility.execute() 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv 
self.execute(*args, **cmd_options) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/core/management/base.py", line 441, in execute 
output = self.handle(*args, **options) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle 
    collected = self.collect() 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect 
    for original_path, processed_path, processed in processor: 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/storage.py", line 33, in post_process 
packager.pack_javascripts(package) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/packager.py", line 112, in pack_javascripts 
return self.pack(package, self.compressor.compress_js, js_compressed, templates=package.templates, **kwargs) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/packager.py", line 105, in pack 
paths = self.compile(package.paths, force=True) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/packager.py", line 99, in compile 
return self.compiler.compile(paths, force=force) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/compilers/__init__.py", line 54, in compile 
return list(executor.map(_compile, paths)) 
    File "/usr/lib64/python3.4/concurrent/futures/_base.py", line 549, in result_iterator 
yield future.result() 
    File "/usr/lib64/python3.4/concurrent/futures/_base.py", line 402, in result 
return self.__get_result() 
    File "/usr/lib64/python3.4/concurrent/futures/_base.py", line 354, in __get_result 
raise self._exception 
    File "/usr/lib64/python3.4/concurrent/futures/thread.py", line 54, in run 
result = self.fn(*self.args, **self.kwargs) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/compilers/__init__.py", line 42, in _compile 
outdated=outdated, force=force) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline_browserify/compiler.py", line 28, in compile_file 
return self.execute_command(command, cwd=dirname(infile)) 
    File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/pipeline/compilers/__init__.py", line 135, in execute_command 
raise CompilerError(e) 
pipeline.exceptions.CompilerError: [Errno 2] No such file or directory: ' ' 

Django的管道設置文件

# Django Pipeline (and browserify) 
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' 

STATICFILES_FINDERS = ( 
    'django.contrib.staticfiles.finders.FileSystemFinder', 
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
    'pipeline.finders.PipelineFinder', 
) 

PIPELINE = { 
    'PIPELINE_ENABLED' : True, 
    'COMPILERS' : ('pipeline_browserify.compiler.BrowserifyCompiler',), 
    'CSS_COMPRESSOR' : 'pipeline.compressors.NoopCompressor', 
    'JS_COMPRESSOR' :'pipeline.compressors.uglifyjs.UglifyJSCompressor', 
    'STYLESHEETS' : { 
     'animelist_css': { 
      'source_filenames': ('animelist/css/style.css',), 
      'output_filename': 'animelist/css/animelist_css.css', 
     } 
    }, 
    'JAVASCRIPT': { 
     'animelist_js': { 
      'source_filenames': (
       'animelist/js/bower_components/jquery/dist/jquery.min.js', 
       'animelist/js/bower_components/react/JSXTransformer.js', 
       'animelist/js/bower_components/react/react-with-addons.js', 
       'animelist/js/app.browserify.js', 
      ), 
      'output_filename': 'animelist/js/animelist.js', 
     } 
    ,} 
} 

if DEBUG: 
    PIPELINE['BROWSERIFY_ARGUMENTS'] = '-t babelify' 

回答

1

顯然,這個問題是由於Django的流水線browserify(0.2.0)不是與Django的管道(1.6的最新版本兼容。 X)。因此,我做了一個原始項目的分支並更新了代碼。您可以複製並粘貼我的repo中的compiler.py,並替換使用pip安裝的那個。

Repo here

我將作出對原回購很快得到它更新一個新的拉請求。希望老闆能夠儘快把它推到點子上。

相關問題