install gulp browserify gives error always

2019-05-08 23:50发布

问题:

Im trying to install gulp-browserify with this command:

npm install gulp-browserify --save-dev

I already installed many other packages successfully like

gulp-autoprefixer
gulp-concat
gulp-minify-css
gulp-sass
gulp-uglify

all of those installations worked great, here is how my package.json file looks like

{
  "devDependencies": {
    "gulp-autoprefixer": "0.0.8",
    "gulp-sass": "~0.7.2",
    "gulp": "~3.8.5",
    "gulp-minify-css": "~0.3.6",
    "gulp-concat": "~2.2.0",
    "gulp-uglify": "~0.3.1"
  }
}

and here is the errors I get when installing browserify

http GET https://registry.npmjs.org/uglify-to-browserify
npm http 200 https://registry.npmjs.org/inline-source-map
npm http GET https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.3.0.tgz
npm ERR! Error: invalid version: 3001.0001.0000-dev-harmony-fb
npm ERR!     at validVersion (/usr/lib/nodejs/read-package-json/read-json.js:573:40)
npm ERR!     at final (/usr/lib/nodejs/read-package-json/read-json.js:323:23)
npm ERR!     at /usr/lib/nodejs/read-package-json/read-json.js:139:33
npm ERR!     at cb (/usr/lib/nodejs/slide/lib/async-map.js:48:11)
npm ERR!     at /usr/lib/nodejs/read-package-json/read-json.js:251:40
npm ERR!     at fs.js:268:14
npm ERR!     at /usr/lib/nodejs/graceful-fs/graceful-fs.js:103:5
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /media/tzookb/dynamic/www/meeters/npm-debug.log npm

npm ERR! System Linux 3.11.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "gulp-browserify" "--save-dev"
npm ERR! cwd /media/tzookb/dynamic/www/meeters
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm http 200 https://registry.npmjs.org/escodegen
npm http GET https://registry.npmjs.org/escodegen/-/escodegen-1.1.0.tgz
npm http 200 https://registry.npmjs.org/callsite
npm http GET https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz
npm http 200 https://registry.npmjs.org/resolve/-/resolve-0.3.1.tgz
npm http 200 https://registry.npmjs.org/astw
npm http GET https://registry.npmjs.org/astw/-/astw-1.1.0.tgz
npm http 200 https://registry.npmjs.org/uglify-js/-/uglify-js-2.2.5.tgz
npm http 200 https://registry.npmjs.org/convert-source-map/-/convert-source-map-0.3.4.tgz
npm http 200 https://registry.npmjs.org/source-map
npm http GET https://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz
npm http 200 https://registry.npmjs.org/source-map
npm http 200 https://registry.npmjs.org/uglify-to-browserify
npm http GET https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz
npm http 200 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/async/-/async-0.2.10.tgz
npm http 200 https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz
npm http 200 https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.3.0.tgz
npm http 200 https://registry.npmjs.org/escodegen/-/escodegen-1.1.0.tgz
npm http 200 https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz
npm http 200 https://registry.npmjs.org/astw/-/astw-1.1.0.tgz
npm http 200 https://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz
npm http 200 https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz
npm http 200 https://registry.npmjs.org/async/-/async-0.2.10.tgz
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz
npm http GET https://registry.npmjs.org/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz
npm http 200 https://registry.npmjs.org/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/amdefine
npm http 200 https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz
npm http 200 https://registry.npmjs.org/amdefine
npm http GET https://registry.npmjs.org/amdefine/-/amdefine-0.1.0.tgz
npm http 200 https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz
npm http 200 https://registry.npmjs.org/amdefine/-/amdefine-0.1.0.tgz
npm ERR! Error: ENOENT, lstat '/media/tzookb/dynamic/www/meeters/node_modules/gulp-browserify/node_modules/browserify/node_modules/umd/node_modules/ruglify/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/amdefine.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /media/tzookb/dynamic/www/meeters/npm-debug.log npm

npm ERR! System Linux 3.11.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "gulp-browserify" "--save-dev"
npm ERR! cwd /media/tzookb/dynamic/www/meeters
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! path /media/tzookb/dynamic/www/meeters/node_modules/gulp-browserify/node_modules/browserify/node_modules/umd/node_modules/ruglify/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/amdefine.js
npm ERR! fstream_path /media/tzookb/dynamic/www/meeters/node_modules/gulp-browserify/node_modules/browserify/node_modules/umd/node_modules/ruglify/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/amdefine.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /media/tzookb/dynamic/www/meeters/npm-debug.log
npm ERR! not ok code 0

回答1:

Which version of node are you running? The kind of error that you are having normally show up when you are trying to install newer modules on an older version of node.

1 - rm -rf node_modules

2 - update node to the latest version

  2.1 - sudo npm cache clean -f
  2.2 - sudo npm install -g n
  2.3 - sudo n stable

3 - try to install gulp-browsify again