Initiate Vue from npm

Initiate Vue from npm

John DowJohn Dow Posts: 16Questions: 6Answers: 0

I have a simple application of two files

"type": "module",
"devDependencies": {
    "nodemon": "^3.0.1"
  "dependencies": {
    "": "^1.13.6",
    "": "^2.1.3",
    "ejs": "^3.1.9",
    "express": "^4.18.2"


<!DOCTYPE html>
<html lang="en">
  <head id="vueHead">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css">
    <title>{{ title }}</title>
    <div class="container" id="vueBody">
      <div class="card"> 
        <h1>{{ h1 }}</h1>
        <DataTable class="display">
    <!-- <script src=""></script> -->
    <script src="app.js" type="module"></script>


import DataTable from ''
import DataTablesCore from ''


const body = {
  data() {
    return {
      h1: 'Its black site',

const head = {
  data() {
    return {
      title: 'Its black site',


In Google Chrome i have the error in Console JS Uncaught TypeError: Failed to resolve module specifier "". Relative references must start with either "/", "./", or "../".

The table is not generated. What am I doing wrong?What am I doing wrong?

This question has an accepted answers - jump to answer


  • allanallan Posts: 60,903Questions: 1Answers: 9,927 Site admin

    You are loading the app.js directly into the browser? You aren't "compiling" it using a bundler such as WebPack, Vite or ESBuild? If so, then you need to tell your browser where the modules you are trying to import from are. That can be done with an Import Map - I wrote a detailed blog post about that.

    The two other options you have are:

    1. Package the code using Vite or similar. See the Vite docs for details
    2. Import DataTables as a global, similar to how you are doing with Vue, rather than as a module.
    <link href="" rel="stylesheet">
    <script src=""></script>
    <script src=""></script>


  • John DowJohn Dow Posts: 16Questions: 6Answers: 0

    Good article Alan, in other words this is best to use a CDN now.

  • allanallan Posts: 60,903Questions: 1Answers: 9,927 Site admin
    Answer ✓

    You need to get the code onto the client-side somehow. Using our CDN is one option. The other is to package the files and deliver them from your own server.


Sign In or Register to comment.