当前位置: 动力学知识库 > 问答 > 编程问答 >

npm - Browserify Task error

问题描述:

Just started using gulp not long ago, everything works fine before this when I'm stuck at this error. I've tried

//gulpfile.js

var gulp = require('gulp'),

browserify = require('browserify'),

source = require('vinyl-source-stream');

// Browserify task

gulp.task('browserify', function() {

return browserify(['app/scripts/app.js'], {debug:true})

.bundle()

.pipe(source('bundle.js'))

.pipe(gulp.dest('dist/scripts'))

});

Error when running gulp browserify

events.js:141

throw er; // Unhandled 'error' event

^

SyntaxError: Unterminated string constant

Where does this syntax error point to? I've read up some articles on the errors in package.json file too.

"devDependencies": {

"browserify": "^13.0.0",

"gulp": "^3.9.1",

"gulp-autoprefixer": "^3.1.0",

"gulp-clean-css": "^2.0.4",

"gulp-connect": "^3.2.1",

"gulp-imagemin": "^2.4.0",

"gulp-less": "^3.0.5",

"gulp-plumber": "^1.1.0",

"gulp-uglify": "^1.5.3",

"vinyl-source-stream": "^1.1.0"

},

"dependencies": {

"angular": "^1.5.3",

"imagemin-pngquant": "^4.2.2"

}

//browserify package.json

{

"name": "browserify",

"version": "13.0.0",

"description": "browser-side require() the node way",

"main": "index.js",

"bin": {

"browserify": "bin/cmd.js"

},

"repository": {

"type": "git",

"url": "git+ssh://[email protected]/substack/node-browserify.git"

},

"keywords": [

"browser",

"require",

"commonjs",

"commonj-esque",

"bundle",

"npm",

"javascript"

],

"dependencies": {

"JSONStream": "^1.0.3",

"assert": "~1.3.0",

"browser-pack": "^6.0.1",

"browser-resolve": "^1.11.0",

"browserify-zlib": "~0.1.2",

"buffer": "^4.1.0",

"concat-stream": "~1.5.1",

"console-browserify": "^1.1.0",

"constants-browserify": "~1.0.0",

"crypto-browserify": "^3.0.0",

"defined": "^1.0.0",

"deps-sort": "^2.0.0",

"domain-browser": "~1.1.0",

"duplexer2": "~0.1.2",

"events": "~1.1.0",

"glob": "^5.0.15",

"has": "^1.0.0",

"htmlescape": "^1.1.0",

"stream-http": "^2.0.0",

"https-browserify": "~0.0.0",

"inherits": "~2.0.1",

"insert-module-globals": "^7.0.0",

"isarray": "0.0.1",

"labeled-stream-splicer": "^2.0.0",

"module-deps": "^4.0.2",

"os-browserify": "~0.1.1",

"parents": "^1.0.1",

"path-browserify": "~0.0.0",

"process": "~0.11.0",

"punycode": "^1.3.2",

"querystring-es3": "~0.2.0",

"read-only-stream": "^2.0.0",

"readable-stream": "^2.0.2",

"resolve": "^1.1.4",

"shasum": "^1.0.0",

"shell-quote": "^1.4.3",

"stream-browserify": "^2.0.0",

"string_decoder": "~0.10.0",

"subarg": "^1.0.0",

"syntax-error": "^1.1.1",

"through2": "^2.0.0",

"timers-browserify": "^1.0.1",

"tty-browserify": "~0.0.0",

"url": "~0.11.0",

"util": "~0.10.1",

"vm-browserify": "~0.0.1",

"xtend": "^4.0.0"

},

"devDependencies": {

"backbone": "~0.9.2",

"browser-unpack": "^1.1.1",

"coffee-script": "~1.10.0",

"coffeeify": "~1.1.0",

"es6ify": "~0.4.8",

"isstream": "^0.1.2",

"seq": "0.3.5",

"tap": "^2.2.0",

"temp": "^0.8.1",

"through": "^2.3.4"

},

"author": {

"name": "James Halliday",

"email": "[email protected]",

"url": "http://substack.net"

},

"scripts": {

"test": "tap test/*.js"

},

"license": "MIT",

"gitHead": "5b82a2f1bc061cb47ff4aa7c702ed79fc20effa8",

"bugs": {

"url": "https://github.com/substack/node-browserify/issues"

},

"homepage": "https://github.com/substack/node-browserify#readme",

"_id": "[email protected]",

"_shasum": "8f223bb24ff4ee4335e6bea9671de294e43ba6a3",

"_from": "[email protected]",

"_npmVersion": "2.14.7",

"_nodeVersion": "4.2.3",

"_npmUser": {

"name": "feross",

"email": "[email protected]"

},

"dist": {

"shasum": "8f223bb24ff4ee4335e6bea9671de294e43ba6a3",

"tarball": "http://registry.npmjs.org/browserify/-/browserify- 13.0.0.tgz"

},

"maintainers": [

{

"name": "domenic",

"email": "[email protected]"

},

{

"name": "dominictarr",

"email": "[email protected]"

},

{

"name": "feross",

"email": "[email protected]"

},

{

"name": "jmm",

"email": "[email protected]"

},

{

"name": "mafintosh",

"email": "[email protected]"

},

{

"name": "maxogden",

"email": "[email protected]"

},

{

"name": "mellowmelon",

"email": "[email protected]"

},

{

"name": "substack",

"email": "[email protected]"

},

{

"name": "terinjokes",

"email": "[email protected]"

},

{

"name": "thlorenz",

"email": "[email protected]"

},

{

"name": "zertosh",

"email": "[email protected]"

}

],

"directories": {},

"_resolved": "https://registry.npmjs.org/browserify/-/browserify-13.0.0.tgz",

"readme": "ERROR: No README data found!"

}

网友答案:

I manage to run this without error by adding

{
  "devDependencies": {
    "browserify": "^13.0.0",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.0",
    "gulp-clean-css": "^2.0.4",
    "gulp-connect": "^3.2.1",
    "gulp-imagemin": "^2.4.0",
    "gulp-less": "^3.0.5",
    "gulp-plumber": "^1.1.0",
    "gulp-uglify": "^1.5.3",
    "vinyl-source-stream": "^1.1.0"
  },
  "dependencies": {
    "angular": "^1.5.3",
    "imagemin-pngquant": "^4.2.2"
  },
  //Tells browserify to use browserify-shim
  "browserify": {
    "transform": [ "browserify-shim" ]
  },
  "browserify-shim": {
    "./app/scripts/app.js": "$"
  }
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: