从外部js api文件构建npm模块 [英] Building npm module from external js api file

查看:90
本文介绍了从外部js api文件构建npm模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从此存储库构建npm软件包, js文件,IntelliJ在看到<script src="">标签时会下载该文件,该文件称为http_www.webglearth.com_v2_api.js

因此,我已按照 npm官方的说明进行操作和 treehouse ,但是每次我尝试执行操作时,都会不断收到npm ERR! not a package错误消息npm install在该项目中,我已经将尝试上传到了我的Git-hub帐户,是package.json的样子:

 {
  "name": "(web_gl_earth_module)",
  "version": "1.0.0",
  "description": "An npm package to help integrate WEBGL Earth to Angular apps",
  "main": "http_www.webglearth.com_v2_api.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "(https://github.com/webglearth/webglearth2.git)"
  },
  "keywords": [
    "webglearth",
    "globe",
    "visualisation"
  ],
  "author": " (git_hub accounts: petrsloup, klokan)",
  "license": "(Apache-2.0)"
}

我已经浏览过类似的错误,但是没有任何案例能真正解决我的问题,我不确定我是否尝试正确的方法或者它是否可行.

我的最终目标是能够将此存储库导入到Angular项目中,现在这是完全不可能的

解决方案

好,所以我设法使用整个存储库而不是min文件来构建我的npm和bower软件包.这个问题真是愚蠢.

在遵循树屋教程时,我发现以下用于安装软件包的命令:

现在,人们会认为treehouse/是主目录,而treehouse_profile.js是一个javascript文件,错了……treehouse_profile.js是根文件夹.

以下是gitHub中回购名称的屏幕截图:

因此,剩下的就是角度积分,那是另一个不错的选择,您可以在this repo, I have the "minified" js file, which IntelliJ downloads when seeing the <script src=""> tag, the file is called http_www.webglearth.com_v2_api.js

So, I've followed instructions as per npm official and treehouse, but keep getting an npm ERR! not a package error message every time I try to do npm install on the project, I have uploaded my attempt to my Git-hub account, this is what the package.json looks like:

 {
  "name": "(web_gl_earth_module)",
  "version": "1.0.0",
  "description": "An npm package to help integrate WEBGL Earth to Angular apps",
  "main": "http_www.webglearth.com_v2_api.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "(https://github.com/webglearth/webglearth2.git)"
  },
  "keywords": [
    "webglearth",
    "globe",
    "visualisation"
  ],
  "author": " (git_hub accounts: petrsloup, klokan)",
  "license": "(Apache-2.0)"
}

I've had a browse for similar errors, but no case scenario really matches my issue, I'm not sure that I'm attempting this the right way or that it's even feasible.

My final goal is to be able to import this repository into an Angular project, which is now completely impossible

解决方案

Ok, so I've managed to build my npm and bower package using the whole repository rather than the min file. The issue was really stupid.

When following the treehouse tutorial I find this command for installing the package:

Now, one would think that treehouse/ is the main directory and treehouse_profile.js is a javascript file, wrong... treehouse_profile.js is the root folder Lesson learned: careful where you pick your tutorials

Here's screenshot of the name of the repo in gitHub:

So, left with the angular integration, that's another good one, you can follow up in this question

这篇关于从外部js api文件构建npm模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆