[英]How to "npm start" an html file with css stylesheet?
I'm new to coding and (obviously) getting Qs in stack overflow allows me to interact more with other developers.我是编码新手,并且(显然)在堆栈溢出中获取 Q 允许我与其他开发人员进行更多交互。
I code on VS Code and I know there is a "live server" extension in order to do exactly what I need my code to do.我在 VS Code 上编码,并且我知道有一个“实时服务器”扩展,以便完全执行我需要我的代码执行的操作。 BUT, up until the last time I tried "npm start" for another code it was working and now I'm starting a simple html/css/js code it just says:
但是,直到我最后一次尝试“npm start”来获取另一个正在运行的代码,现在我开始了一个简单的 html/css/js 代码,它只是说:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\.\..\...\....\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\.\..\...\....\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
I've done a bit of research and I know i need to either run npm install
or npm init
.我做了一些研究,我知道我需要运行
npm install
或npm init
。
However my npm install
won't fix the issue, and the npm init
does create the package.json
file, BUT won't fix the issue. However my
npm install
won't fix the issue, and the npm init
does create the package.json
file, BUT won't fix the issue.
Also, after running npm init
, it says I don't have the "start" script, and even after I set up the script, it won't work.另外,运行
npm init
后,它说我没有“启动”脚本,即使我设置了脚本,它也不起作用。
I've already:我已经:
I don't know what else to do.我不知道还能做什么。
First off let me say you do not need npm or live server to view a simple HTML, CSS and JS project.首先让我说您不需要 npm 或实时服务器来查看简单的 HTML、CSS 和 JS 项目。 You can just open the HTML file using your web browser.
您可以使用 web 浏览器打开 HTML 文件。 Assuming you know that let me cover what the npm commands are doing because it confused me at first.
假设您知道,让我介绍一下 npm 命令正在做什么,因为它起初让我感到困惑。
The start command in your package.json is just the bit of code that gets run when you actually type npm start. package.json 中的启动命令只是当您实际键入 npm start 时运行的代码位。 Basically what it all comes down to is you do not need to run any sort of start command unless your application needs to run on a server which a simple HTML CSS and JS does not.
基本上,这一切都归结为您不需要运行任何类型的启动命令,除非您的应用程序需要在简单的 HTML CSS 和 JS 不需要的服务器上运行。
Live Server is similar to what happens when you run the start command it is just an extension offered through VSCode. Live Server 类似于运行 start 命令时发生的情况,它只是通过 VSCode 提供的扩展。 Another useful extension I use is "Open in default browser" for my basic HTML CSS and JS files.
我使用的另一个有用的扩展是“在默认浏览器中打开”,用于我的基本 HTML CSS 和 JS 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.