imcvampire/vue-axios

"npm run build" reports this error

Sphinxone opened this issue · 5 comments

When i build my vue project,i got this error.

WARNING in ./src/main.js
23:8-16 "export 'default' (imported as 'VueAxios') was not found in 'vue-axios'
@ ./src/main.js

ERROR in static/js/vendor.334ceea9e3e48015f1fc.js from UglifyJs
Unexpected token name «NODE_ENV», expected punc «,» [./node_modules/vue-axios/dist/vue-axios.es5.js:1,3159][static/js/vendor.334ceea9e3e48015f1fc.js:
35428,173]

Build failed with errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-webgis@1.0.0 build: node build/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-webgis@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

i have searched many method,but i can not solve this problem.

hi @Sphinxone, could you provide your vue and vue-axios version, or link a simple demo? I tested with vue 2/3 + vue-aixos@3.2.5, and can't reproduce above error.

hi @Sphinxone, could you provide your vue and vue-axios version, or link a simple demo? I tested with vue 2/3 + vue-aixos@3.2.5, and can't reproduce above error.

thanks for your reply!

my two project all report this problem.

my vue and vue-axios is following:
"vue-axios": "^3.2.4"
"vue": "^2.5.2"
"axios": "^0.21.1"

i try to use vue-axios@3.2.5 and report same problem

@Sphinxone Please try removing ^ from "vue-axios": "^3.2.4", because ^ symbol indicates that the latest version of the current minor version is downloaded, so at last you are still using vue-axios@3.2.5.

the build format changed to umd in v3.2.5, which may cause above error. could you provide your build.js script?

@Sphinxone Please try removing ^ from "vue-axios": "^3.2.4", because ^ symbol indicates that the latest version of the current minor version is downloaded, so at last you are still using vue-axios@3.2.5.

the build format changed to umd in v3.2.5, which may cause above error. could you provide your build.js script?

I check node_modules, my vue-axios has changed to 3.2.5,because i use npm unintall and npm install.
my build.js is following and i review vue-axios's package.json and find it requiers vue3.0.0 but my vue is 2.x.Could this causes error?

`'use strict'
require('./check-versions')()

process.env.NODE_ENV = 'production'

const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')

const spinner = ora('building for production...')
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')

if (stats.hasErrors()) {
  console.log(chalk.red('  Build failed with errors.\n'))
  process.exit(1)
}

console.log(chalk.cyan('  Build complete.\n'))
console.log(chalk.yellow(
  '  Tip: built files are meant to be served over an HTTP server.\n' +
  '  Opening index.html over file:// won\'t work.\n'
))

})
})
`

vue-axios@3.2.5 also support Vue 2, please see my demo: https://github.com/Alanscut/vue-axios-test

serve the server/app.js first, then run the vue project with npm run serve, you will find the vue 2 works well with vue-axios@3.2.5.