Building npm module from external js api file

2019-05-21 12:19发布

I'm trying to build an npm package from 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

2条回答
贼婆χ
2楼-- · 2019-05-21 12:51

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:

enter image description here

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:

enter image description here

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

查看更多
男人必须洒脱
3楼-- · 2019-05-21 13:04

The name & version in package.json should be unique as compared available npm packages repo

查看更多
登录 后发表回答