在Heroku上使用django-pipeline运行collectstatic的权限被拒绝

时间:2018-07-11 16:40:49

标签: django heroku sass node-sass django-pipeline

我有一个Django 2.0项目,该项目使用django-pipeline编译器将pipeline.compilers.sass.SASSCompiler用于静态文件。它在开发中可以完美运行,但是当我在Heroku上部署它时,在运行collectstatic时出现以下错误:

pipeline.exceptions.CompilerError: [Errno 13] Permission denied: '/app/node_modules/.bin'

管道配置:

PIPELINE['SASS_BINARY'] = '/app/node_modules/.bin node-sass'

package.json

{
  "name": "myprojectname",
  "version": "1.0.0",
  "engines": {
    "node": "8.11.3"
  },
  "description": "myprojectdescription",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "bower install"
  },
  "dependencies": {
    "bower": "^1.8.4",
    "node-sass": "^4.9.2",
    "yuglify": "^2.0.0"
  } 
}

bower.json

{
  "name": "myprojectname",
  "main": "index.js",
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "app/static/bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap4": "bootstrap#^4.1.1",
    "bootstrap-datepicker": "^1.8.0",
    "font-awesome": "^5.1.0"
  }
}

我尝试使用sass安装npm(“ sass”:“ ^ 1.9.0”),并将管道配置更改为

PIPELINE['SASS_BINARY'] = '/app/.heroku/node/bin sass'

但是它仍然失败,并显示相同的错误:

pipeline.exceptions.CompilerError: [Errno 13] Permission denied: '/app/.heroku/node/bin'

从日志和heroku run bash中,我可以看到所有列出的节点软件包都已成功安装。如何解决此权限错误?

1 个答案:

答案 0 :(得分:0)

问题出在node-sass的路径上。一定是

PIPELINE['SASS_BINARY'] = '/app/node_modules/.bin/node-sass'