VueJS website won't deploy npm run dev gives error: "build command failed"

Hey all I know there are a lot of topics about this subject and I can assure you I’ve tried at least 10 of those topics! But none of these seem to work for me unfortunately…

Also I am very new to this so I don’t even understand a lot of the answers in topics…

This is my Netlify URL

So I am trying to deploy my VueJS website with the Vue Material Kit theme from Creative Tim but everytime I try to deploy with these deploy settings:

Base directory: Not set
Build command: npm run build
(I also tried this with the “CI=”)
Publish directory: dist

I run this locally with npm run dev on localhost:8080 and I can commit and push succesfully to my (privte) Gitlab Repo

This is my deploy message:

8:11:26 PM: Build ready to start
8:11:29 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
8:11:29 PM: build-image tag: v4.8.0
8:11:29 PM: buildbot version: e58b6be665675c0f99b33132a8c1eec1f775eba1
8:11:29 PM: Fetching cached dependencies
8:11:30 PM: Failed to fetch cache, continuing with build
8:11:30 PM: Starting to prepare the repo for build
8:11:30 PM: No cached dependencies found. Cloning fresh repo
8:11:30 PM: git clone git@gitlab.com:NickvBruggen/nvb
8:11:32 PM: Preparing Git Reference refs/heads/main
8:11:32 PM: Parsing package.json dependencies
8:11:34 PM: Starting build script
8:11:34 PM: Installing dependencies
8:11:34 PM: Python version set to 2.7
8:11:35 PM: v16.14.2 is already installed.
8:11:36 PM: Now using node v16.14.2 (npm v8.5.0)
8:11:36 PM: Started restoring cached build plugins
8:11:36 PM: Finished restoring cached build plugins
8:11:36 PM: Attempting ruby version 2.7.2, read from environment
8:11:38 PM: Using ruby version 2.7.2
8:11:39 PM: Using PHP version 8.0
8:11:39 PM: No npm workspaces detected
8:11:39 PM: Started restoring cached node modules
8:11:39 PM: Finished restoring cached node modules
8:11:40 PM: Installing NPM modules using NPM version 8.5.0
8:12:25 PM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
8:12:26 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
8:12:26 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
8:12:26 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
8:12:26 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
8:12:29 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
8:12:32 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
8:12:36 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
8:12:37 PM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
8:12:37 PM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
8:12:38 PM: npm WARN deprecated eslint-loader@2.2.1: This loader has been deprecated. Please use eslint-webpack-plugin
8:12:40 PM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
8:12:41 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
8:12:42 PM: npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported
8:12:42 PM: npm WARN deprecated babel-eslint@10.0.3: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
8:12:43 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
8:12:45 PM: npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
8:12:46 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
8:12:46 PM: npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
8:12:52 PM: added 1518 packages, and audited 1519 packages in 1m
8:12:52 PM: 98 packages are looking for funding
8:12:52 PM:   run `npm fund` for details
8:12:52 PM: 24 vulnerabilities (7 moderate, 17 high)
8:12:52 PM: To address issues that do not require attention, run:
8:12:52 PM:   npm audit fix
8:12:52 PM: To address all issues (including breaking changes), run:
8:12:52 PM:   npm audit fix --force
8:12:52 PM: Run `npm audit` for details.
8:12:52 PM: NPM modules installed
8:12:52 PM: Started restoring cached go cache
8:12:52 PM: Finished restoring cached go cache
8:12:52 PM: go version go1.16.5 linux/amd64
8:12:52 PM: go version go1.16.5 linux/amd64
8:12:52 PM: Installing missing commands
8:12:52 PM: Verify run directory
8:12:55 PM: ​
8:12:55 PM: ────────────────────────────────────────────────────────────────
8:12:55 PM:   Netlify Build                                                 
8:12:55 PM: ────────────────────────────────────────────────────────────────
8:12:55 PM: ​
8:12:55 PM: ❯ Version
8:12:55 PM:   @netlify/build 27.0.1
8:12:55 PM: ​
8:12:55 PM: ❯ Flags
8:12:55 PM:   baseRelDir: true
8:12:55 PM:   buildId: 6264414efbbef7000849936d
8:12:55 PM:   deployId: 6264414efbbef7000849936f
8:12:55 PM: ​
8:12:55 PM: ❯ Current directory
8:12:55 PM:   /opt/build/repo
8:12:55 PM: ​
8:12:55 PM: ❯ Config file
8:12:55 PM:   No config file was defined: using default values.
8:12:55 PM: ​
8:12:55 PM: ❯ Context
8:12:55 PM:   production
8:12:55 PM: ​
8:12:55 PM: ────────────────────────────────────────────────────────────────
8:12:55 PM:   1. Build command from Netlify app                             
8:12:55 PM: ────────────────────────────────────────────────────────────────
8:12:55 PM: ​
8:12:55 PM: $ npm run build
8:12:55 PM: > vue-material-kit@1.2.2 build
8:12:55 PM: > vue-cli-service build && gulp licenses
8:12:56 PM: -  Building for production...
8:13:26 PM:  WARNING  Compiled with 4 warnings6:13:26 PM
8:13:26 PM:  warning  in ./src/main.js
8:13:26 PM: Module Warning (from ./node_modules/thread-loader/dist/cjs.js):
8:13:26 PM: 
8:13:26 PM: /opt/build/repo/src/main.js
8:13:26 PM:   37:10  warning  Delete `·`  prettier/prettier
8:13:26 PM: 
8:13:26 PM: ✖ 1 problem (0 errors, 1 warning)
8:13:26 PM:   0 errors and 1 warning potentially fixable with the `--fix` option.
8:13:26 PM: 
8:13:26 PM:  @ multi ./src/main.js
8:13:26 PM:  warning 
8:13:26 PM: asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
8:13:26 PM: This can impact web performance.
8:13:26 PM: Assets:
8:13:26 PM:   img/city-profile.3b3fb65f.jpg (247 KiB)
8:13:26 PM:   img/PDSM.fbaddb9d.jpg (432 KiB)
8:13:26 PM:   img/MYSTIS.4ccb4ae4.jpg (465 KiB)
8:13:26 PM:   img/VSO.ac6ebaaa.jpg (462 KiB)
8:13:26 PM:   img/MAYENA.5359386b.jpg (443 KiB)
8:13:26 PM:   css/app.34e0d546.css (246 KiB)
8:13:26 PM:   js/chunk-vendors.9d03fe24.js (655 KiB)
8:13:26 PM:  warning 
8:13:26 PM: entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
8:13:26 PM: Entrypoints:
8:13:26 PM:   app (1.03 MiB)
8:13:26 PM:       css/chunk-vendors.5458cd99.css
8:13:26 PM:       js/chunk-vendors.9d03fe24.js
8:13:26 PM:       css/app.34e0d546.css
8:13:26 PM:       js/app.364e8af5.js
8:13:26 PM:  warning 
8:13:26 PM: webpack performance recommendations:
8:13:26 PM: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
8:13:26 PM: For more info visit https://webpack.js.org/guides/code-splitting/
8:13:26 PM:   File                                   Size              Gzipped
8:13:26 PM:   dist/js/chunk-vendors.9d03fe24.js      655.40 KiB        170.61 KiB
8:13:26 PM:   dist/js/app.364e8af5.js                25.77 KiB         7.36 KiB
8:13:26 PM:   dist/css/app.34e0d546.css              246.02 KiB        27.34 KiB
8:13:26 PM:   dist/css/chunk-vendors.5458cd99.css    129.47 KiB        17.65 KiB
8:13:26 PM:   Images and other types of assets omitted.
8:13:26 PM:  DONE  Build complete. The dist directory is ready to be deployed.
8:13:26 PM:  INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html
8:13:28 PM: [18:13:28] Using gulpfile /opt/build/repo/gulpfile.js
8:13:28 PM: [18:13:28] Task never defined: licenses
8:13:28 PM: [18:13:28] To list available tasks, try running: gulp --tasks
8:13:28 PM: ​
8:13:28 PM: ────────────────────────────────────────────────────────────────
8:13:28 PM:   "build.command" failed                                        
8:13:28 PM: ────────────────────────────────────────────────────────────────
8:13:28 PM: ​
8:13:28 PM:   Error message
8:13:28 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
8:13:28 PM: ​
8:13:28 PM:   Error location
8:13:28 PM:   In Build command from Netlify app:
8:13:28 PM:   npm run build
8:13:28 PM: ​
8:13:28 PM:   Resolved config
8:13:28 PM:   build:
8:13:28 PM:     command: npm run build
8:13:28 PM:     commandOrigin: ui
8:13:28 PM:     publish: /opt/build/repo/dist
8:13:28 PM:     publishOrigin: ui
8:13:29 PM: Caching artifacts
8:13:29 PM: Started saving node modules
8:13:29 PM: Finished saving node modules
8:13:29 PM: Started saving build plugins
8:13:29 PM: Finished saving build plugins
8:13:29 PM: Started saving pip cache
8:13:29 PM: Finished saving pip cache
8:13:29 PM: Started saving emacs cask dependencies
8:13:29 PM: Finished saving emacs cask dependencies
8:13:29 PM: Started saving maven dependencies
8:13:29 PM: Finished saving maven dependencies
8:13:29 PM: Started saving boot dependencies
8:13:29 PM: Finished saving boot dependencies
8:13:29 PM: Started saving rust rustup cache
8:13:29 PM: Finished saving rust rustup cache
8:13:29 PM: Started saving go dependencies
8:13:29 PM: Finished saving go dependencies
8:13:30 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:13:30 PM: Creating deploy upload records
8:13:30 PM: Failing build: Failed to build site
8:13:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:13:31 PM: Finished processing build request in 2m1.259116643s

As I said I am very new to this so I don’t understand everything and I just can’t see what I am doing wrong…

I fixed my own issue FINALLY!

I changed some code of the package.json file:

From

"scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build && gulp licenses ",
    "lint": "vue-cli-service lint",
    "dev": "npm run serve",
    "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm run dev"
 },

To

"scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "dev": "npm run serve",
    "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm run dev"
 },

So I removed && gulp licenses didn’t know why it was there but that did the job