当我启动webpack-dev-server时,我收到此错误:
ERROR in multi main
Module not found: Error: Cannot resolve 'file' or 'directory' /var/www/html/151208-DressingAphrodite/app in /var/www/html/151208-DressingAphrodite
@ multi main
Run Code Online (Sandbox Code Playgroud)
这是我的webpack.config.js:
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require ('html-webpack-plugin');
const PATHS = {
app: path.join (__dirname, 'app'),
build : path.join (__dirname, 'build')
};
module.exports = {
entry : [
'babel-polyfill',
'webpack-dev-server/client?http://localhost:8080',
PATHS.app
],
output : {
publicPath : '/',
filename : 'dressingaphrodite.js',
hash : true
},
debug : true,
devServer : {
contentBase : './app' …
Run Code Online (Sandbox Code Playgroud) javascript node.js webpack webpack-dev-server npm-live-server
尝试在 Visual Studio Code 中调试一个简单的 HTML 和 JavaScript 项目。在 VS Code 终端窗口中,“live-server”用于启动“index.html”。在 VS Code 中,安装并配置了“Chrome 调试器”。即使在 Chrome 浏览器中启动页面后,调试器也不会附加并给出错误消息“无法连接到运行时进程,10000 毫秒后超时 - (原因:无法连接到目标:连接 ECONNREFUSED 127.0.0.1:9222) .'。
启动文件
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}",
"urlFilter": "http://localhost:8080"
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against index.html",
"file": "${workspaceRoot}/index.html"
}
]
Run Code Online (Sandbox Code Playgroud)
Chrome 的快捷方式修改为包括 --remote-debugging-port=9222
是否可以在 JavaScript 文件的 VS Code 中使用“实时服务器”并调试或设置断点?
我在全球范围内安装了live-server:
npm install -g live-server
但由于某种原因,它没有找到,我得到以下错误
bash: live-server: command not found
在命令之后
live-server
一切都正确安装:
/Users/username/npm-global/bin/live-server ->
/Users/username/npm-global/lib/node_modules/live-server/live-server.js
live-server@0.9.2 /Users/username/npm-global/lib/node_modules/live-server
??? object-assign@4.0.1
??? colors@1.1.2
??? event-stream@3.3.2 (pause-stream@0.0.11, duplexer@0.1.1, stream-combiner@0.0.4, from@0.1.3, map-stream@0.1.0, split@0.3.3, through@2.3.8)
??? opn@4.0.0 (pinkie-promise@2.0.0)
??? send@0.13.1 (escape-html@1.0.3, destroy@1.0.4, statuses@1.2.1, etag@1.7.0, fresh@0.3.0, range-parser@1.0.3, ms@0.7.1, debug@2.2.0, depd@1.1.0, mime@1.3.4, on-finished@2.3.0, http-errors@1.3.1)
??? morgan@1.7.0 (on-headers@1.0.1, basic-auth@1.0.3, depd@1.1.0, on-finished@2.3.0, debug@2.2.0)
??? connect@3.4.1 (utils-merge@1.0.0, parseurl@1.3.1, debug@2.2.0, finalhandler@0.4.1)
??? faye-websocket@0.10.0 (websocket-driver@0.6.4)
??? watchr@2.3.10 (bal-util@1.18.0)
??? serve-index@1.7.3 (parseurl@1.3.1, escape-html@1.0.3, batch@0.5.3, http-errors@1.3.1, debug@2.2.0, mime-types@2.1.10, accepts@1.2.13)
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我正在尝试让浏览器同步在我的项目中工作,而不是使用live-server
应用程序结构如下所示:
personal-app
??? node_modules
??? src
??? app
? ??? app.ts
??? index.html
Run Code Online (Sandbox Code Playgroud)
在index.html中,脚本从node_modules dir 加载
<script src="../node_modules/systemjs/dist/system.src.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
Run Code Online (Sandbox Code Playgroud)
当我使用live-server时,它会加载脚本并且工作正常,但是由于我移动到浏览器同步,脚本不会加载.这是gulpfile.js中的代码:
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: "./src"
}
});
gulp.watch(sassfiles, ['sass']);
gulp.watch(htmlfiles).on('change', browserSync.reload);
});
Run Code Online (Sandbox Code Playgroud)
当我将src路径作为基础目录时,baseDir: "./src"
该站点可以工作,但脚本不会加载
但当我改变它 baseDir: "./"
该网站给了我不能GET /,但是当我将"/ src"添加到chrome中的url时,如" http:// localhost:3000/src ",它可以工作.
所以这里的问题是浏览器同步不会从其baseDir的父文件夹加载脚本.
我需要一种方法来配置浏览器同步以从其启动baseDir : "./"
但从子文件夹加载主页index.html.
浏览器同步可能吗?
我开始尝试 lit-html 和 lit-elements,玩弄它,现在我遇到了无法找到如何在线发布此类代码的问题。从来没有在在线平台上使用过 Node-js 包,只使用了它的一些代码。通常我构建普通的 php/html 模板,但我想试试这个。
在本地构建一些有效的测试用例。但是到处搜索以了解如何将这种代码在线发布到互联网上。我正在使用具有许多选项(例如 SSH)的共享主机,例如但无法找到如何使其正常工作,它不能像在我的服务器上运行 npm install 一样简单,对吗?
我使用live-server与实时重新加载文件夹HTML
,javascript
并CSS
使用Visual Studio Code
。
当我在Google Chrome浏览器中打开控制台时,会看到此信息
“无法加载资源:服务器以404(未找到)状态响应 http://eluxer.net/code?sesscheck=1&id=105&subid=51824_5848_ “
我尝试使用许多不同的文件夹进行此操作,并且每次使用实时服务器时都出现相同的消息。同时,当我HTML
直接在浏览器中打开文件时(没有实时服务器),没有错误消息。
拜托,谁能告诉我该如何解决?
google-chrome livereload visual-studio-code npm-live-server nodejs-liveserver
我有一个与我的 html 文件链接的 css 文件。通过实时服务器加载 html 文件时,我的 css 不起作用。
直接通过浏览器打开 html 文件时,css 工作正常。我的 css 文件位于 html 文件所在的目录之外。当我的 npm 脚本使用 live-server 作为 npm start 时,没有任何参数,它只显示我的工作区的所有文件,如果我点击我的 html 文件所在的目录,css 将起作用。但是如果我添加 html 文件作为 live-server 的参数,它只会加载 html 文件而没有任何 css 更改。
html:
<link rel='stylesheet' type='text/css' href='../styles.css'>
Run Code Online (Sandbox Code Playgroud)
包.json:
"start": "live-server home/index.html"
Run Code Online (Sandbox Code Playgroud)
或者
"start": "live-server home"
Run Code Online (Sandbox Code Playgroud)
或者
"start": "live-server home/index.html && styles.css"
Run Code Online (Sandbox Code Playgroud)
都有相同的结果。仅有的
"start": "live-server"
Run Code Online (Sandbox Code Playgroud)
works,它显示浏览器上的工作目录。我单击主目录,然后使用 css 加载 html 文件。
从终端输入 npm start 时,我的 html 文件可以在浏览器上正常加载,但由于某种原因链接的 css 文件没有加载。css 链接代码应该没问题,因为它在直接从浏览器打开时可以正常工作。css文件需要在同一个目录下吗?
我使用的是 Windows 10,并且在我的本地机器上安装了 Node.js(带有 npm)。我正在尝试遵循以下说明:
"Once node.js and npm are installed, run the following command in your terminal.
npm install -g live-server
This will install live-server?, a simple static server that has live reload built-in. To
start your server, run live-server in your terminal from the root /code folder —
it will even open a new browser window for you!"
Run Code Online (Sandbox Code Playgroud)
由于我在 Windows 上,我猜“终端”的意思是“命令提示符”。所以,我已经npm install -g live-server
从 C:// 提示符运行了“ ”。
我现在对它说“live-server
从根 /code 文件夹在您的终端中运行”的部分感到困惑。
是什么root /code folder …
我正在尝试设置reactjs项目并使用live-server.我的项目结构 -
fa/
-node-modules/
...
-public/
bundle.js
index.html
-src/
app.js
package.json
Run Code Online (Sandbox Code Playgroud)
我的package.json文件 -
{
"name": "fa",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "watchify src/app.js -o public/bundle.js -t [ babelify --presets [ react es2015 ] ]",
"server": "cd public; live-server --port=1234 --entry-file=index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babelify": "^7.3.0",
"live-server": "^1.1.0",
"watchify": "^3.7.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我跑了一个cmd"npm run build",然后是"npm run server".它给出了错误 -
17 error Windows_NT 6.2.9200
18 error argv "E:\\Program Files\\nodejs\\node.exe" …
Run Code Online (Sandbox Code Playgroud) 每次我的页面第一次加载时我都会收到此消息。当我尝试使用控制台测试我的应用程序时,这确实让我和我的经历感到困扰。我尝试在谷歌上寻找解决方案,但没有找到。我不知道这是否是一些基本问题,所以如果是的话,我将非常感谢我得到的任何帮助。
我希望使用某些设置或者完全修复它来从我的控制台中删除此消息。
npm-live-server ×10
node.js ×5
npm ×4
javascript ×2
bash ×1
browser-sync ×1
css ×1
deployment ×1
gulp ×1
html ×1
lit-element ×1
lit-html ×1
livereload ×1
package.json ×1
webpack ×1