np icon indicating copy to clipboard operation
np copied to clipboard

np prerelease error: Unexpected token u in JSON at position 0

Open andreken opened this issue 2 years ago • 4 comments

Description

When I execute the command np and choose prerelease I receive the following error message: Unexpected token u in JSON at position 0 This happens when I have already created a prerelease and I'm trying to update it. The first time I published the prerelease (v5.0.0-0) it worked as expected.

package.json
{
  "version": "5.0.0-0",
  "engines": {
    "node": ">=14 <15",
    "npm": ">=6 <7"
  },
  ...
  "files": [
    "lib",
    "dist"
  ],
  "scripts": {
    "start": "rimraf .tmp/* && BABEL_ENV=development webpack-dev-server --config webpack.dev.config.js",
    "eslint": "eslint src/ --ext .js --ext .jsx",
    "eslint:fix": "eslint src/ --ext .js --ext .jsx --fix",
    "build:lib": "rimraf lib/* && BABEL_ENV=production babel src --out-dir lib",
    "build:dist": "rimraf dist/* && BABEL_ENV=production webpack --config webpack.prod.config.js",
    "prebuild": "npm run eslint",
    "build": "npm run build:lib && npm run build:dist",
    "deploy": "npm run build && np",
    "test": ""
  },
  "peerDependencies": {
   ...
  },
  "dependencies": {
  ...
  },
  "devDependencies": {
  ...
  }
}

Steps to reproduce

  1. Move to a branch already published in prerelease (in my case different to master)
  2. Run npm run deploy -- --any-branch
  3. Select semver: prerelease (in my case 5.0.0-1)
  4. Unexpected token u in JSON at position 0

Expected behavior

A new prerelease is created, with tag v5.0.0-1

Temporary workaround

Run npx np prerelease --any-branch --tag=beta

Environment

np - 7.6.0 Node.js - 14.18.1 npm - 6.14.15 Git - 2.30.1 OS - macOS 11.5.1

andreken avatar Apr 15 '22 10:04 andreken

Similar error here.

image

Environment

np - 8.0.4 Node.js - 16.20.0 npm - 9.0.0 OS - ubuntu 20.04

AnnyCaroline avatar Jun 14 '23 15:06 AnnyCaroline

This is still an issue with [email protected] / Node.js v20.10.0 - can't do a pre-release:

image
? Select SemVer increment or specify new version prerelease     0.0.1-0

✖ SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Module.prereleaseTags (file:///F:/DEV/open-source/contributing/posthtml-i18n/node_modules/np/source/npm/util.js:92:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.choices (file:///F:/DEV/open-source/contributing/posthtml-i18n/node_modules/np/source/ui.js:312:36)

Cosmin@work MINGW64 /f/DEV/open-source/contributing/posthtml-i18n (master)
$ npm list np
[email protected] F:\DEV\open-source\contributing\posthtml-i18n
└── [email protected]


Cosmin@work MINGW64 /f/DEV/open-source/contributing/posthtml-i18n (master)
$ node -v
v20.10.0

Had to publish a patch release instead (0.0.1), which worked fine.

cossssmin avatar Jan 10 '24 12:01 cossssmin