geraintluff / tv4

Tiny Validator for JSON Schema v4
http://geraintluff.github.io/tv4/
Other
1.17k stars 183 forks source link

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

Open netmilk opened 9 years ago

netmilk commented 9 years ago

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
tv4@1.1.3 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": "luffgd@gmail.com"
    }
  ],
  "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": "tv4@1.1.3",
  "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": "luffgd@gmail.com"
  },
  "directories": {},
  "_shasum": "26e5a98a564dd3c6a2aee06b246450f040079134",
  "_resolved": "https://registry.npmjs.org/tv4/-/tv4-1.1.3.tgz",
  "readme": "ERROR: No README data found!"
}
NoumanSaleem commented 9 years ago

:+1:

michaelsharpe commented 9 years ago

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.

osukaa commented 9 years ago

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?

michaelsharpe commented 9 years ago

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.

limianwang commented 9 years ago

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

michaelsharpe commented 9 years ago

There is however now a tv4.min.js present in the root. On Oct 6, 2014 7:22 PM, "Limian Wang" notifications@github.com 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.

limianwang commented 9 years ago

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

okunishinishi commented 9 years ago

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

Bartvds commented 9 years ago

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).

geraintluff commented 9 years ago

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.

Bartvds commented 9 years ago

@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.

geraintluff commented 9 years ago

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

oliveti commented 8 years ago

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.