我對我的角度客戶端應用使用browserify。我需要使用下劃線。角安裝有涼亭和下劃線安裝有NPM如果需要下劃線,browserify源地圖不起作用
我這是怎麼運行browserify(NPM)和創建一飲而盡(NPM)源地圖
gulp.task('browserify', function() {
return browserify(dir.script_from + '/main.js', {debug: true})
.bundle()
.pipe(source('bundle.js')) // gives streaming vinyl file object
.pipe(buffer()) // <----- convert from streaming to buffered vinyl file object
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify()) // now gulp-uglify works
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dir.script_to));
});
在我main.js,我有
//require('underscore')
require('angular')
require('angular-resource')
require('angular-route')
require('./home/home_page.js')
...
如果我不需要('下劃線'),源地圖正在工作。我可以查看原始文件並設置斷點。
但是,如果我需要( '下劃線'),源地圖不再工作。我甚至無法查看這些文件。
我也嘗試安裝與鮑爾強調,但我得到了以下錯誤:
[23:59:02] Starting 'browserify'...
events.js:85
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'underscore' from '/Users/[my path]/app/client/script'
注意兩個涼亭(我config'ed路徑),在NPM放模塊的/用戶/ [我的路徑]/node_modules'文件夾
我甚至嘗試了main.js只有一行:require('underscore')
和不工作,但空main.js文件工作
你有錯誤?如:「下劃線未定義」 – marcel
@marcel npm沒有錯誤,'找不到'涼亭。 – John
你是怎麼安裝'underscore'的? – marcel