tv4 icon indicating copy to clipboard operation
tv4 copied to clipboard

Critical: main .js file declared in package.json is not part of the package

Open netmilk opened this issue 10 years ago • 13 comments

Hi, I found out that latest release 1.1.3 is not usable. Even if package is installed, it's resulting to:

kolotoc:dredd-example netmilk$ dredd

module.js:340
    throw err;
          ^
Error: Cannot find module 'tv4'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Users/netmilk/.nvm/v0.8.23/lib/node_modules/dredd/node_modules/gavel/lib/validators/json-schema.js:7:7)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

The reason is that the main file declared in package.json is not part of the distributed package. When I switch main to tv4.js which is distributed, it works.

Details:


kolotoc:tv4_test netmilk$ npm install tv4
[email protected] node_modules/tv4
kolotoc:tv4_test netmilk$ cd node_modules/tv4
kolotoc:tv4 netmilk$ ls
LICENSE.txt     lang            props.js        tv4.js
README.md       package.json        tv4.async-jquery.js
kolotoc:tv4 netmilk$ cat package.json 
{
  "name": "tv4",
  "version": "1.1.3",
  "author": {
    "name": "Geraint Luff"
  },
  "description": "A public domain JSON Schema validator for JavaScript",
  "keywords": [
    "json-schema",
    "schema",
    "validator",
    "tv4"
  ],
  "maintainers": [
    {
      "name": "geraintluff",
      "email": "[email protected]"
    }
  ],
  "main": "tv4.min.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/geraintluff/tv4.git"
  },
  "license:": [
    {
      "type": "Public Domain",
      "url": "http://geraintluff.github.io/tv4/LICENSE.txt"
    },
    {
      "type": "MIT",
      "url": "http://jsonary.com/LICENSE.txt"
    }
  ],
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-clean": "~0.4.1",
    "grunt-contrib-jshint": "~0.6.2",
    "mocha": "~1.11.0",
    "grunt-mocha": "~0.4",
    "grunt-mocha-test": "~0.5.0",
    "grunt-cli": "~0.1.9",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-contrib-copy": "~0.4.1",
    "proclaim": "1.4",
    "mocha-unfunk-reporter": "~0.2",
    "jshint-path-reporter": "~0.1",
    "grunt-concat-sourcemap": "~0.2",
    "source-map-support": "~0.1",
    "grunt-markdown": "~0.3.0",
    "grunt-push-release": "~0.1.1",
    "grunt-regex-replace": "~0.2.5",
    "requirejs": "~2.1.11",
    "grunt-component-io": "~0.1.0"
  },
  "engines": {
    "node": ">= 0.8.0"
  },
  "scripts": {
    "test": "grunt test",
    "prepublish": "grunt prepublish"
  },
  "bugs": {
    "url": "https://github.com/geraintluff/tv4/issues"
  },
  "homepage": "https://github.com/geraintluff/tv4",
  "_id": "[email protected]",
  "dist": {
    "shasum": "26e5a98a564dd3c6a2aee06b246450f040079134",
    "tarball": "http://registry.npmjs.org/tv4/-/tv4-1.1.3.tgz"
  },
  "_from": "tv4@>=1.1.0-0 <1.2.0-0",
  "_npmVersion": "1.4.0",
  "_npmUser": {
    "name": "geraintluff",
    "email": "[email protected]"
  },
  "directories": {},
  "_shasum": "26e5a98a564dd3c6a2aee06b246450f040079134",
  "_resolved": "https://registry.npmjs.org/tv4/-/tv4-1.1.3.tgz",
  "readme": "ERROR: No README data found!"
}

netmilk avatar Oct 06 '14 12:10 netmilk

:+1:

NoumanSaleem avatar Oct 06 '14 17:10 NoumanSaleem

So it looks like this change hasn't propagated onto NPM. This may be because the version number hasn't changed, so NPM won't think to pull the newer version with this fix. As it stands, the version that NPM is serving up is broken.

parzival418 avatar Oct 06 '14 20:10 parzival418

Thanks for writing about this because we were having the same issue with Cannot find module 'tv4' and changing from tv4.min.js to tv4.js gave us the solution.

How long does it take for npm to propagate the change?

osukaa avatar Oct 06 '14 20:10 osukaa

I am not sure. I suspect it might be because the version number hasn't changed since this tiny bug was fixed, but that is only my suspicion.

parzival418 avatar Oct 06 '14 20:10 parzival418

I don't think this change has been applied. It is still marked as tv4.min.js on the master branch.

limianwang avatar Oct 06 '14 23:10 limianwang

There is however now a tv4.min.js present in the root. On Oct 6, 2014 7:22 PM, "Limian Wang" [email protected] wrote:

I don't think this change has been applied. It is still marked as tv4.min.js on the master branch.

— Reply to this email directly or view it on GitHub https://github.com/geraintluff/tv4/issues/157#issuecomment-58115446.

parzival418 avatar Oct 06 '14 23:10 parzival418

npm install tv4 does not provide me with the tv4.min.js. I'm still having the same issue.

limianwang avatar Oct 06 '14 23:10 limianwang

I'm having the same issue, too.

tv4.min.js seems to be ignored by npm because of the pattern /*.min.js written in .npmignore file .

https://github.com/geraintluff/tv4/blob/5f6199477a948ef60069361cf3d8606f001983f6/.npmignore

okunishinishi avatar Oct 07 '14 06:10 okunishinishi

I pinged and emailed @geraintluff on all known addresses, I hope he checks in soon to republish (I can push to github but not to npm).

Bartvds avatar Oct 07 '14 07:10 Bartvds

Hi - sorry it took me so long to respond. I've pushed a fix tv4.js in v1.1.4.

I sincerely apologise for this - I hadn't realised .min.js versions were in .npmignore. Local tests and Travis seemed happy, so I hadn't realised there was a problem.

@Bartvds - I've add you as an owner on NPM.

geraintluff avatar Oct 07 '14 10:10 geraintluff

@geraintluff Cool; will be handy for emergencies like this. I'll see if I can harden the build to validate these kind of package reference issues too.

Bartvds avatar Oct 07 '14 13:10 Bartvds

Thanks - I'm afraid I wasn't really aware of what was in .npmignore, so that was a bit of a surprise. :astonished:

geraintluff avatar Oct 07 '14 13:10 geraintluff

Hi,

The issue with the missing min.js file is still there (because of the content of .npmignore). Do you plan to change this at some point ?

Thank you.

oliveti avatar Feb 15 '16 14:02 oliveti