1
我遇到了lodash問題。當我部署使用一飲而盡我總是同樣的錯誤:無法部署lodash
vendors.min.js:3 GET http://127.0.0.1/projects/myproject/lodash 404 (Not Found)
我宣佈庫到我的index.html文件
<script src="node_modules/lodash/lodash.js"></script>
我導入lodash到我打字稿文件
///<reference path="../../../typings/modules/lodash/index.d.ts" />
import * as _ from "lodash";
這是當我測試我的網站localy(通過啓動精簡版服務器與npm啓動)的工作。
現在,我想用Gulp部署我的網站。這是我的一飲而盡文件:
gulp.task('app-bundle', function() {
var tsProject = ts.createProject('tsconfig.json', {
typescript: require('typescript'),
outFile: 'app.js'
});
var tsResult = gulp.src([
'node_modules/angular2/typings/browser.d.ts',
'typings/main/ambient/firebase/firebase.d.ts',
'app/**/*.ts'
])
.pipe(ts(tsProject));
return tsResult.js.pipe(addsrc.append('config-prod.js'))
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('vendor-bundle', function() {
gulp.src([
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/rxjs/bundles/Rx.js',
'node_modules/angular2/bundles/angular2.dev.js',
'node_modules/angular2/bundles/http.dev.js',
'node_modules/angular2/bundles/router.min.js',
'node_modules/lodash/lodash.js'
])
.pipe(concat('vendors.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('default',[ 'app-bundle', 'vendor-bundle' ], function() {
gulp.src('index.html')
.pipe(htmlreplace({
'vendor': 'vendors.min.js',
'app': 'app.min.js'
}))
.pipe(gulp.dest('dist'));
});
當我測試我的網站,我有以下錯誤:
vendors.min.js:3 GET http://127.0.0.1/projects/myproject/lodash 404 (Not Found)r @ vendors.min.js:3e.scheduleTask @ vendors.min.js:3e.scheduleMacroTask @ vendors.min.js:3(anonymous function) @ vendors.min.js:3send @ VM3157:3L @ vendors.min.js:4(anonymous function) @ vendors.min.js:4e @ vendors.min.js:3(anonymous function) @ vendors.min.js:4(anonymous function) @ vendors.min.js:4(anonymous function) @ vendors.min.js:5(anonymous function) @ vendors.min.js:5(anonymous function) @ vendors.min.js:5(anonymous function) @ vendors.min.js:5(anonymous function) @ vendors.min.js:5(anonymous function) @ vendors.min.js:4e.invoke @ vendors.min.js:3e.run @ vendors.min.js:3(anonymous function) @ vendors.min.js:3e.invokeTask @ vendors.min.js:3e.runTask @ vendors.min.js:3o @ vendors.min.js:3invoke @ vendors.min.js:3
vendors.min.js:3 Error: XHR error (404 Not Found) loading http://127.0.0.1/projects/myproject/lodash
Error loading http://127.0.0.1/projects/myproject/lodash as "lodash" from http://127.0.0.1/projects/myproject/services/base-services/base.services
at o (http://127.0.0.1/projects/myproject/vendors.min.js:4:10124)
at XMLHttpRequest.L.a.onreadystatechange (http://127.0.0.1/projects/myproject/vendors.min.js:4:10712)
at XMLHttpRequest.t [as _onreadystatechange] (http://127.0.0.1/projects/myproject/vendors.min.js:3:12638)
at e.invokeTask (http://127.0.0.1/projects/myproject/vendors.min.js:3:8519)
at e.runTask (http://127.0.0.1/projects/myproject/vendors.min.js:3:5879)
at XMLHttpRequest.invoke (http://127.0.0.1/projects/myproject/vendors.min.js:3:9628)
這裏是我的SystemJS:
System.config({
paths: {
'rxjs/add/observable/*' : 'node_modules/rxjs/add/observable/*.js',
'rxjs/add/operator/*' : 'node_modules/rxjs/add/operator/*.js',
'rxjs/*' : 'node_modules/rxjs/*.js'
},
map: {
'@angular' : 'angular2',
'videogular2' : 'node_modules/videogular2',
'rxjs': 'node_modules/rxjs',
'lodash': 'node_modules/lodash'
},
packages: {
map: {
'rxjs': 'node_modules/rxjs'
},
app: {
format: 'register',
defaultExtension: 'js'
},
node_modules: {
defaultExtension: 'js'
},
lodash:{
main:'lodash',
defaultExtension:'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
我因爲許多搜索天解決方案,我真的很感激任何幫助:)。
當我部署,我補充一點,劇本太:
document.addEventListener('DOMContentLoaded', function() {
System.import('boot')
.then(null, console.error.bind(console));
});
你的SystemJS配置如何? – rinukkusu
嗨,我已經使用SystemJS配置更新了我的帖子。 – Ivan
有人嗎? ...:'[ – Ivan