Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoIncreaseVersion fails with Error while parsing JSON - Unexpected end of JSON input #53

Open
JeffJassky opened this issue Sep 17, 2021 · 0 comments

Comments

@JeffJassky
Copy link

JeffJassky commented Sep 17, 2021

ISSUE DESCRIPTION:
Running build script deletes all contents from package.json.
Build then immediately fails with Error while parsing JSON - Unexpected end of JSON input.

VERSION INFO:

webpack-auto-inject-vesion: 1.2.2
Webpack: 4.46.0
@vue/cli 4.5.13
Vue: 2.6.14

BUILD COMMAND:

cross-env NODE_ENV=production vue-cli-service ssr:build --env.patch

PLUGIN CONFIGURATION:

new WebpackAutoInject({
  silent: false,
  components: {
    AutoIncreaseVersion: true,
    InjectAsComment: false,
    InjectByTag: false
  },
  componentsOptions: {
    AutoIncreaseVersion: {
      runInWatchMode: false // it will increase version with every single build!
    }
  }
})

PACKAGE.JSON CONTENTS

{
	"name": "vue-app",
	"version": "0.2.0",
	"private": true,
	"scripts": {
		"lint": "vue-cli-service lint",
		"serve": "vue-cli-service serve",
		"build": "vue-cli-service build",
		"ssr:serve": "vue-cli-service ssr:serve",
		"ssr:build": "cross-env NODE_ENV=production vue-cli-service ssr:build --env.patch",
		"ssr:start": "cross-env NODE_ENV=production vue-cli-service ssr:serve --mode production",
		"ssr:start:pm2": "./node_modules/.bin/pm2 start pm2.config.js && ./node_modules/.bin/pm2 logs WEB"
	},
	"dependencies": {
		"axios": "^0.21.1",
		"cors": "^2.8.5",
		"express-device": "^0.4.2",
		"express-ip": "^1.0.4",
		"imagekit": "^3.2.2",
		"imagekit-javascript": "^1.4.1",
		"node-fetch": "^3.0.0",
		"nuxtjs-sticky-sidebar": "^1.2.0",
		"shebang-loader": "^0.0.1",
		"vue": "^2.6.11",
		"vue-carousel": "^0.18.0",
		"vue-debounce": "^3.0.1",
		"vue-lazy-hydration": "^2.0.0-beta.4",
		"vue-router": "^3.2.0",
		"vue-select": "^3.12.1",
		"vue-server-renderer": "^2.6.0",
		"vue-slick-carousel": "^1.0.6",
		"vuex": "^3.4.0",
		"vuex-persist": "^3.1.3",
		"vuex-persistedstate": "^4.0.0",
		"winston": "^3.3.3"
	},
	"devDependencies": {
		"@akryum/vue-cli-plugin-ssr": "~0.6.0",
		"@vue/cli-plugin-babel": "~4.5.0",
		"@vue/cli-plugin-eslint": "~4.5.0",
		"@vue/cli-plugin-pwa": "~4.5.0",
		"@vue/cli-plugin-router": "~4.5.0",
		"@vue/cli-plugin-vuex": "~4.5.0",
		"@vue/cli-service": "~4.5.0",
		"@vue/eslint-config-airbnb": "^5.0.2",
		"babel-eslint": "^10.1.0",
		"eslint": "^6.7.2",
		"eslint-plugin-import": "^2.20.2",
		"eslint-plugin-vue": "^6.2.2",
		"express": "^4.17.1",
		"less": "^4.1.1",
		"less-loader": "^5.0.0",
		"pm2": "^5.1.1",
		"ssr-window": "^4.0.0",
		"vue-loader-v16": "^16.0.0-beta.5.4",
		"vue-server-renderer": "^2.6.14",
		"vue-template-compiler": "^2.6.11",
		"webpack-auto-inject-version": "^1.2.2",
		"webpack-bundle-analyzer": "^4.4.2",
		"webpack-shell-plugin": "^0.5.0"
	}
}

CONSOLE OUTPUT:

[AIV] :  info : Auto inject version started
 ERROR  SyntaxError: /package.json: Error while parsing JSON - Unexpected end of JSON input
SyntaxError: /package.json: Error while parsing JSON - Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /node_modules/@babel/core/lib/config/files/package.js:55:20
    at /node_modules/@babel/core/lib/config/files/utils.js:30:12
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/node_modules/@babel/core/lib/gensync-utils/async.js:24:3)
    at Generator.next (<anonymous>)
    at evaluateSync (/node_modules/gensync/index.js:251:28)
    at Function.sync (/node_modules/gensync/index.js:89:14)
    at sync (/node_modules/@babel/core/lib/gensync-utils/async.js:67:25)
    at sync (/node_modules/gensync/index.js:182:19)

MY BEST GUESS:
It seems to be a problem in babel - this function call is only passing one argument (https://github.com/babel/babel/blob/672a58660f0b15691c44582f1f3fdcdac0fa0d2f/packages/babel-core/src/config/files/package.ts#L23) whereas it seems to want the file contents passed as the second argument according to the function definition here: https://github.com/babel/babel/blob/672a58660f0b15691c44582f1f3fdcdac0fa0d2f/packages/babel-core/src/config/files/package.ts#L36

POSSIBLE SOLUTION
Use a different method to read from/write to package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant