Ionic 1.x - 从 bower 到 npm

6
我曾经在我的ionic 1项目中使用bower安装插件。新趋势,特别是在ionic 2中,是使用npm安装包。一些核心包,例如ionic.cloud,甚至对于ionic 1.x也不再提供bower支持。
因此,我需要将一些包迁移到npm上。有什么推荐的方法吗?
我的问题:
  • "npm install" seems to install packages in the "my_project/node_modules" folder, unlike bower which installs packages directly in my_project/www/lib/
  • As explained for instance in the installation guide of ionic.cloud this requires an additional step to copy the newly installed npm package in the lib folder with the command:

    cp node_modules/@ionic/cloud/dist/bundle/ionic.cloud.min.js www/lib
    
然而,当我更新软件包并运行“npm update”时,这将更新node_modules文件夹,但不会更新lib文件夹。这是一个问题,因为只有来自我的lib文件夹的文件包括在我的index.html中。
在每次npm更新后运行cp命令似乎不是一种优雅的解决方案。有没有推荐的处理方法?

我目前处理这个问题的方式是在我的npm文件夹(node_modules/myPackage)和我的www/lib文件夹之间创建符号链接。这是我迄今为止找到的较少糟糕的解决方案,但还不够理想,因为我们需要为每个新包创建一个符号链接并记住它的依赖关系。 - Robycool
1个回答

0

我认为你可以反转这个过程,使.bowerrc文件在node_modules文件夹内创建你的包,并将此路径作为默认路径。否则,node_modules是必需的,没有其他方法来创建它。
即使你可以使用npm i --prefix ./bower_components/ <package>,你仍然需要cp到从bower_components文件夹上升的文件夹中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接