Vue: Deploy failed because of "npm run build" not working?

Hi there,

I’m currently working on a Vue app and to check if everything’s working fine in “the real world”, I deployed the boiler plate Vue app created with the Vue UI.

I’ve used the default settings for Package manager and the Default preset, containing babel and eslint.

I’ve not touched the code itself and on my local machine everything is working fine.

As suggested here and here, my build settings are the following:

Build command: npm run build
Publish directory: dist

Looks like the problem is that “npm run build” isn’t properly executed, but why?

Thank you for taking the time reading this and helping me, I appreciate it! :slight_smile:

Main dependencies:

  1. core-js
  2. vue

Development dependencies

  1. babel-eslint
  2. eslint
  3. eslint-plugin-vue
  4. vue-template-compiler

Netlify URL

https://show-weather.netlify.com/

Deploy log

12:12:30 PM: Build ready to start
12:12:32 PM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
12:12:32 PM: build-image tag: v3.3.5
12:12:32 PM: buildbot version: 2fd8f04962d5dbc77b79b9c2f5ab7a077e87376b
12:12:32 PM: Fetching cached dependencies
12:12:32 PM: Failed to fetch cache, continuing with build
12:12:32 PM: Starting to prepare the repo for build
12:12:32 PM: No cached dependencies found. Cloning fresh repo
12:12:32 PM: git clone https://github.com/stevefrenzel/vue-weather-app
12:12:33 PM: Preparing Git Reference refs/heads/master
12:12:33 PM: Starting build script
12:12:33 PM: Installing dependencies
12:12:35 PM: Downloading and installing node v10.19.0…
12:12:35 PM: Downloading https://nodejs.org/dist/v10.19.0/node-v10.19.0-linux-x64.tar.xz
12:12:36 PM:
#################################
12:12:36 PM: 46.4%
12:12:36 PM:
###################################################################
12:12:36 PM: ##### 100.0%
12:12:36 PM: Computing checksum with sha256sum
12:12:36 PM: Checksums matched!
12:12:39 PM: Now using node v10.19.0 (npm v6.13.4)
12:12:39 PM: Attempting ruby version 2.6.2, read from environment
12:12:40 PM: Using ruby version 2.6.2
12:12:41 PM: Using PHP version 5.6
12:12:41 PM: Started restoring cached go cache
12:12:41 PM: Finished restoring cached go cache
12:12:41 PM: unset GOOS;
12:12:41 PM: unset GOARCH;
12:12:41 PM: export GOROOT=’/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
12:12:41 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
12:12:41 PM: go version >&2;
12:12:41 PM: export GIMME_ENV=’/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
12:12:41 PM: go version go1.12 linux/amd64
12:12:41 PM: Installing missing commands
12:12:41 PM: Verify run directory
12:12:41 PM: Executing user command: npm run build
12:12:41 PM: npm
12:12:41 PM: ERR!
12:12:41 PM: code ENOENT
12:12:41 PM: npm
12:12:41 PM: ERR! syscall open
12:12:41 PM: npm
12:12:41 PM: ERR! path /opt/build/repo/package.json
12:12:41 PM: npm
12:12:41 PM: ERR!
12:12:41 PM: errno
12:12:41 PM: -2
12:12:41 PM: npm
12:12:41 PM: ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
12:12:41 PM: npm
12:12:41 PM: ERR! enoent This is related to npm not being able to find a file.
12:12:41 PM: npm ERR!
12:12:41 PM: enoent
12:12:41 PM: npm ERR! A complete log of this run can be found in:
12:12:41 PM: npm ERR!
12:12:41 PM: /opt/buildhome/.npm/_logs/2020-02-20T11_12_41_630Z-debug.log
12:12:41 PM: Skipping functions preparation step: no functions directory set
12:12:41 PM: Caching artifacts
12:12:41 PM: Started saving pip cache
12:12:41 PM: Finished saving pip cache
12:12:41 PM: Started saving emacs cask dependencies
12:12:41 PM: Finished saving emacs cask dependencies
12:12:41 PM: Started saving maven dependencies
12:12:41 PM: Finished saving maven dependencies
12:12:41 PM: Started saving boot dependencies
12:12:41 PM: Finished saving boot dependencies
12:12:41 PM: Started saving go dependencies
12:12:41 PM: Finished saving go dependencies
12:12:44 PM: Error running command: Build script returned non-zero exit code: 254
12:12:44 PM: Failing build: Failed to build site
12:12:44 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 254
12:12:44 PM: Finished processing build request in 12.591898727s

how frustrating. Could you post your package.json file please?

this is what i suggested the last time we saw this error, maybe its helpful:

There you go! :slight_smile:

{
“name”: “vue-weather-app”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“serve”: “vue-cli-service serve”,
“build”: “vue-cli-service build”,
“lint”: “vue-cli-service lint”
},
“dependencies”: {
“core-js”: “^3.6.4”,
“vue”: “^2.6.11”
},
“devDependencies”: {
@vue/cli-plugin-babel”: “~4.2.0”,
@vue/cli-plugin-eslint”: “~4.2.0”,
@vue/cli-service”: “~4.2.0”,
“babel-eslint”: “^10.0.3”,
“eslint”: “^6.7.2”,
“eslint-plugin-vue”: “^6.1.2”,
“vue-template-compiler”: “^2.6.11”
},
“eslintConfig”: {
“root”: true,
“env”: {
“node”: true
},
“extends”: [
“plugin:vue/essential”,
“eslint:recommended”
],
“parserOptions”: {
“parser”: “babel-eslint”
},
“rules”: {}
},
“browserslist”: [
“> 1%”,
“last 2 versions”
]
}

Thank you very much!

So you’re suggesting to deploy the site without a build command? That wouldn’t make sense, as the Vue and Netlify documentary is clear on which build command and publish directory to use when deploying a Vue project…

I think this may be an issue with where the build command is running based on your file structure. Looking at your repo here https://github.com/stevefrenzel/vue-weather-app, you currently have:

vue-weather-app
  |-src
  |-public
  |...
readme

but I believe it needs to be:

src
public
readme
...

Alternatively, you could try to cd in your build command (cd vue-weather-app && npm run build with a dist dir that’s something like vue-weather-app/dist, though I’m not positive that will work.

Wanna give those a shot and report back?

Thank you so much, you were right. It’s working now! :slight_smile:

Awesome, glad to hear :slight_smile: