How can I serve NPM packages using Flask?

后端 未结 3 1309
执笔经年
执笔经年 2020-12-24 12:40

I have a small Flask app which currently sources jQuery and highlight.js from external servers. I\'d like to make these local dependencies which I pull in via NPM.

W

3条回答
  •  醉酒成梦
    2020-12-24 13:22

    maybe a bit late for the answer, but the easiest way to do it is by doing this:

    sudo npm install bower
    echo "bower_components/" >> .gitignore
    bower install -S (here goes whatever you want)
    npm init
    

    Then you fill out the prompt, and you'll have a few new files:

    • bower.json, which is generated by bower to manage dependencies. Using bower install -S (your dependency) will update this file with your new dependencies.
    • package.json, created by npm to manage your project and npm dependencies
    • node_modules, the things you installed with npm
    • bower_components/ which is where all of your front end dependencies live.

提交回复
热议问题