我只是想在我的Bootstrap项目上工作,但是我不能,因为我不能在我的本地服务器上测试任何东西。在我的浏览器中,我得到了错误'Localhost拒绝连接‘。下面写着,ERR_CONNECTION_REFUSED。出于某些原因,它还会在端口3000上自动提供服务,而我认为它通常在端口3000上执行。即使我在url栏中手动输入'localhost:3000‘,它仍然拒绝连接。我觉得这实际上是问题的主要部分。直到我下载了McAfee,我才开始遇到这些问题。从那以后,我同时禁用了McAfee防火墙和McAfee网络顾问。无论如何,我不知道这是否有帮助,但下面是我的package.json、gulpfile.js和bash终端输出的内容,分别是尝试执行'npm start‘时的内容:
{
"title": "Small Business",
"name": "startbootstrap-small-business",
"version": "4.2.1",
"scripts": {
"start": "node_modules/.bin/gulp watch"
},
"description": "A small business HTML template built with Bootstrap",
"keywords": [
"css",
"sass",
"html",
"responsive",
"theme",
"template"
],
"homepage": "https://startbootstrap.com/template-overviews/small-business",
"bugs": {
"url": "https://github.com/BlackrockDigital/startbootstrap-small-business/issues",
"email": "feedback@startbootstrap.com"
},
"license": "MIT",
"author": "Start Bootstrap",
"contributors": [
"David Miller (http://davidmiller.io/)"
],
"repository": {
"type": "git",
"url": "https://github.com/BlackrockDigital/startbootstrap-small-business.git"
},
"dependencies": {
"bootstrap": "4.3.1",
"jquery": "3.4.1"
},
"devDependencies": {
"browser-sync": "2.26.7",
"del": "^4.1.1",
"gulp": "4.0.2",
"merge-stream": "2.0.0"
}
}
"use strict";
// Load plugins
const browsersync = require("browser-sync").create();
const del = require("del");
const gulp = require("gulp");
const merge = require("merge-stream");
// BrowserSync
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./"
},
port: 3000
});
done();
}
// BrowserSync reload
function browserSyncReload(done) {
browsersync.reload();
done();
}
// Clean vendor
function clean() {
return del(["./vendor/"]);
}
// Bring third party dependencies from node_modules into vendor directory
function modules() {
// Bootstrap
var bootstrap = gulp.src('./node_modules/bootstrap/dist/**/*')
.pipe(gulp.dest('./vendor/bootstrap'));
// jQuery
var jquery = gulp.src([
'./node_modules/jquery/dist/*',
'!./node_modules/jquery/dist/core.js'
])
.pipe(gulp.dest('./vendor/jquery'));
return merge(bootstrap, jquery);
}
// Watch files
function watchFiles() {
gulp.watch("./**/*.css", browserSyncReload);
gulp.watch("./**/*.html", browserSyncReload);
}
// Define complex tasks
const vendor = gulp.series(clean, modules);
const build = gulp.series(vendor);
const watch = gulp.series(build, gulp.parallel(watchFiles, browserSync));
// Export tasks
exports.clean = clean;
exports.vendor = vendor;
exports.build = build;
exports.watch = watch;
exports.default = build;
[16:32:23] Using gulpfile ~/Desktop/HHWebsiteFolder/Bootstrap/startbootstrap-small-business/gulpfile.js
[16:32:23] Starting 'watch'...
[16:32:23] Starting 'clean'...
[16:32:23] Finished 'clean' after 9.64 ms
[16:32:23] Starting 'modules'...
[16:32:23] Finished 'modules' after 60 ms
[16:32:23] Starting 'watchFiles'...
[16:32:23] Starting 'browserSync'...
[16:32:23] Finished 'browserSync' after 21 ms
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.1.66:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------
[Browsersync] Serving files from: ./
发布于 2020-04-15 12:01:34
我想通了。我删除了cookie、浏览器历史记录和缓存数据。现在,只要在我的终端输入'npm start‘,我的应用程序就会自动显示localhost:3000,而不是localhost:3443,后者以前根本不起作用。我必须在我的地址栏中输入“127.0.0.1:3000”,它才会在Chrome中显示任何内容。
https://stackoverflow.com/questions/61178581
复制相似问题