Brunch installed with phoenix app doesn't work with bower assets

扶醉桌前 提交于 2019-12-08 02:20:17

问题


I have created Phoenix 1.0.4 (Elixir) application. After I had added some logic in application I wanted to switch my work for front-end part. On page http://www.jonathanbirkholz.com/how-to-use-font-awesome-on-phoenix/ I read that for 3rd assets I should use Bower. Unfortunately with font-awesome or bootstrap-sass from Bower and with command brunch build I always receive:

/.../my_app/node_modules/acorn/dist/acorn.js:1747
  throw err;
  ^

SyntaxError: Unexpected token (2:10)
  at Parser.pp.raise (/.../my_app/node_modules/acorn/dist/acorn.js:1745:13)
  at Parser.pp.unexpected (/.../my_app/node_modules/acorn/dist/acorn.js:2264:8)
  at Parser.pp.semicolon (/.../my_app/node_modules/acorn/dist/acorn.js:2243:59)
  at Parser.pp.parseExpressionStatement (/.../my_app/node_modules/acorn/dist/acorn.js:2677:8)
  at Parser.pp.parseStatement (/.../my_app/node_modules/acorn/dist/acorn.js:2462:160)
  at Parser.pp.parseBlock (/.../my_app/node_modules/acorn/dist/acorn.js:2692:21)
  at Parser.pp.parseStatement (/.../my_app/node_modules/acorn/dist/acorn.js:2443:19)
  at Parser.pp.parseTopLevel (/.../my_app/node_modules/acorn/dist/acorn.js:2379:21)
  at Object.parse (/.../my_app/node_modules/acorn/dist/acorn.js:101:12)
  at parse (/.../my_app/node_modules/detective/index.js:9:18)
  at Function.exports.find (/.../my_app/node_modules/detective/index.js:44:15)
  at module.exports (/.../my_app/node_modules/detective/index.js:23:20)
  at /.../my_app/node_modules/deppack/index.js:83:12
  at tryToString (fs.js:414:3)
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12)

I found that problem is caused by acorn - JavaScript library, so I check dependency tree for Node modules:

├─┬ brunch@2.0.4
│ ├─┬ deppack@0.1.5
│ │ └─┬ detective@4.3.1
│ │   ├── acorn@1.2.2

Brunch 2.0.4 (The newest released) use dependencies for old acorn library. There are newer acorn versions, but detective library allows to use acorn 1.x.x versions.z


回答1:


Probably I found what was wrong. Bower must be installed globally and shouldn't exist locally (in node_modules).




回答2:


I had a similar issue.

Try using Node > 5 and NPM 3, clean your cache and install the node_modules again (delete first).



来源:https://stackoverflow.com/questions/34385107/brunch-installed-with-phoenix-app-doesnt-work-with-bower-assets

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