首页 > 解决方案 > 完成项目后“无法获取/”,yarn创建了项目

问题描述

这是终端图片
所以每当我使用yarn init制作我的项目并设置项目然后当我运行| webpack 开发服务器 | 在我的终端中打开我的本地主机 http://localhost:8080 我看到消息“无法获取 /”而不是我调用的函数。

谢谢 :)

index.js

import $ from 'jquery';
import greet from './greet';

$(document).ready(function () {
  console.log('jQuery just checked that the DOM is ready!');
});

greet('Boris');

包.json

{

 "name": "01-yarn-project",
  "version": "1.0.0",
  "description": "This project has all the initial yaran started frontend project.",
  "main": "index.js",
  "repository": "git@github.com:safi-n/yarn-JS-Front-end.git",
  "author": "safi-n",
  "license": "UNLICENSED",
  "private": true,
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^8.2.2",
    "babel-preset-es2015": "^6.24.1",
    "eslint": "^8.0.1",
    "eslint-plugin-react": "^7.26.1",
    "webpack": "^5.58.2",
    "webpack-cli": "^4.9.0",
    "webpack-dev-server": "^4.3.1"
  },
  "dependencies": {
    "jquery": "^3.6.0"
  }
}

索引.html

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
</head>

<body>
  <script src="dist/bundle.js"></script>

 #tried  <script src="bundle.js"></script> too same result
</body>

</html>

标签: javascriptnode.jsyarnpkg-v2

解决方案


推荐阅读