vuejs / vue-cli

πŸ› οΈ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.33k forks source link

Error on `vue create` command #4732

Open Jabark opened 4 years ago

Jabark commented 4 years ago

Version

4.0.4

Environment info

Environment Info:

  System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 8.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.1419.0
  npmGlobalPackages:
    @vue/cli: Not Found
Environment Info:

  System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.1419.0
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

What is expected?

The command is successful

What is actually happening?

 ERROR  SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at PackageManager.getMetadata (C:\Users\C21869A\AppData\Roaming\nvm\v8.12.0\node_modules\@vue\cli\lib\util\ProjectPackageManager.js:149:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

This is my first time trying out vue. I also tried using a different registry but got the same issue.

Jabark commented 4 years ago

Also worth noting that I've downgraded to version 3.12.1 and I don't get this issue there at all.

Jabark commented 4 years ago

Something of further interest, I just thought I'd try going back to version 4.0.4 and using -m npm in the command. Still seemingly got the error but it did run through and create it:

Vue CLI v4.0.4
✨  Creating project in C:\Users\C21869A\git-repos\vue-getting-started\hello-vue-4.
πŸ—ƒ  Initializing git repository...
βš™  Installing CLI plugins. This might take a while...

(node:24744) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at PackageManager.getMetadata (C:\Users\C21869A\AppData\Roaming\nvm\v10.15.3\node_modules\@vue\cli\lib\util\ProjectPackageManager.js:149:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:24744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting
a promise which was not handled with .catch(). (rejection id: 1)
(node:24744) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

> yorkie@2.0.0 install C:\Users\C21869A\git-repos\vue-getting-started\hello-vue-4\node_modules\yorkie
> node bin/install.js

setting up Git hooks
done

> core-js@3.3.2 postinstall C:\Users\C21869A\git-repos\vue-getting-started\hello-vue-4\node_modules\core-js
> node postinstall || echo "ignore"

> core-js-pure@3.3.2 postinstall C:\Users\C21869A\git-repos\vue-getting-started\hello-vue-4\node_modules\core-js-pure
> node postinstall || echo "ignore"

added 1129 packages from 826 contributors in 92.345s
πŸš€  Invoking generators...
πŸ“¦  Installing additional dependencies...

added 56 packages from 44 contributors in 29.281s
βš“  Running completion hooks...

πŸ“„  Generating README.md...

πŸŽ‰  Successfully created project hello-vue-4.
πŸ‘‰  Get started with the following commands:

 $ cd hello-vue-4
 $ npm run serve
haoqunjiang commented 4 years ago

So according to the output, the error is raised when parsing the result of yarn info vue-cli-version-marker --json. Could you try to execute this command in your terminal and see if it successfully returns? It's usually a network according to my experience.

Jabark commented 4 years ago
$ yarn info vue-cli-version-marker --json
{"type":"error","data":"Received invalid response from npm."}
Jabark commented 4 years ago
$ yarn info vue-cli-version-marker --json --verbose
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\vue-getting-started\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\.npmrc\"."}
{"type":"verbose","data":"Found configuration file \"C:\\\\Users\\\\C21869A\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Program Files\\\\nodejs\\\\etc\\\\npmrc\"."}
{"type":"verbose","data":"Found configuration file \"C:\\\\Program Files\\\\nodejs\\\\etc\\\\npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\vue-getting-started\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\.npmrc\"."}
{"type":"verbose","data":"Found configuration file \"C:\\\\Users\\\\C21869A\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\.npmrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\vue-getting-started\\\\.yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\.yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Program Files\\\\nodejs\\\\etc\\\\yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\vue-getting-started\\\\.yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\git-repos\\\\.yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\C21869A\\\\.yarnrc\"."}
{"type":"verbose","data":"Checking for configuration file \"C:\\\\Users\\\\.yarnrc\"."}
{"type":"verbose","data":"current time: 2019-10-21T15:13:57.647Z"}
{"type":"verbose","data":"Performing \"GET\" request to \"https://artifactory.of.our.company.local/artifactory/api/npm/admin-portal/vue-cli-version-marker\"."}
{"type":"error","data":"Received invalid response from npm."}
mathworld commented 4 years ago

Same here, node 10.16.3, npx --package @vue/cli vue 4.0.4. Using WebStorm to create the project, fails with: /Users/xyz/.nvm/versions/node/v10.16.3/bin/node /Users/xyz/.nvm/versions/node/v10.16.3/lib/node_modules/npm/bin/npx-cli.js --package @vue/cli vue create . ERROR SyntaxError: Unexpected end of JSON input SyntaxError: Unexpected end of JSON input at JSON.parse () at PackageManager.getMetadata (/Users/xyz/.npm/_npx/8191/lib/node_modules/@vue/cli/lib/util/ProjectPackageManager.js:149:21) at process._tickCallback (internal/process/next_tick.js:68:7) Done

Any help appreciated, thanks

allan-christian commented 4 years ago

I'm having the same issue using vue ui to create a project. If I try to create it via command line:

vue create vue-ui --skipGetStarted --packageManager npm --force --no-git --inlinePreset {"useConfigFiles":false,"plugins":{"@vue/cli-plugin-babel":{},"@vue/cli-plugin-router":{"historyMode":true},"@vue/cli-plugin-vuex":{},"@vue/cli-plugin-eslint":{"config":"standard","lintOn":["save"]}},"cssPreprocessor":"node-sass"}

I got the following error:

zsh: no matches found: plugins:@vue/cli-plugin-eslint:lintOn:[save]

haoqunjiang commented 4 years ago

So the problem is that your company's internal npm registry does not support yarn info or npm info, thus the version check throws. That should be fixed on the registry side. Though, we can have a fallback logic in the CLI. And since the version check is not critical, the error should be catched.

haoqunjiang commented 4 years ago

@allan-christian Wrap the JSON in a pair of quotation marks.

vue create vue-ui --skipGetStarted --packageManager npm --force --no-git --inlinePreset '{"useConfigFiles":false,"plugins":{"@vue/cli-plugin-babel":{},"@vue/cli-plugin-router":{"historyMode":true},"@vue/cli-plugin-vuex":{},"@vue/cli-plugin-eslint":{"config":"standard","lintOn":["save"]}},"cssPreprocessor":"node-sass"}'
Jabark commented 4 years ago

So the problem is that your company's internal npm registry does not support yarn info or npm info, thus the version check throws. That should be fixed on the registry side. Though, we can have a fallback logic in the CLI. And since the version check is not critical, the error should be catched.

Not sure what you mean. Seems to work fine:

$ npm info software-ui-saas-library

software-ui-saas-library@18.9.0 | LicenseRef-LICENSE | deps: 19 | versions: 77
Common component/service library for SaaS Portal UI

dist
.tarball: https://artifactory.of.our.company.local/artifactory/api/npm/admin-portal/software-ui-saas-library/-/software-ui-saas-library-18.9.0.tgz
.shasum: 07d68e122911680d9642e6d0ef34fb522b2c84d2

dependencies:
@angular/animations: ^7.2.15               angular2-uuid: 1.1.1
@angular/common: ^7.2.15                   flat: 4.1.0
@angular/compiler: ^7.2.15                 moment-timezone: ^0.5.26
@angular/core: ^7.2.15                     moment: ^2.24.0
@angular/forms: ^7.2.15                    ng2-cookies: 1.0.12
@angular/platform-browser-dynamic: ^7.2.15 roboto-fontface: 0.7.0
@angular/platform-browser: ^7.2.15         rxjs: ^6.5.3
@angular/router: ^7.2.15                   tslib: ^1.9.0
@types/flat: 0.0.28                        zone.js: ^0.8.29
@types/moment-timezone: ^0.5.12

dist-tags:
latest: 18.9.0

published a week ago
$ npm info moment

moment@2.24.0 | MIT | deps: none | versions: 62
Parse, validate, manipulate, and display dates
http://momentjs.com

keywords: moment, date, time, parse, format, validate, i18n, l10n, ender

dist
.tarball: https://artifactory.of.our.company.local/artifactory/api/npm/admin-portal/moment/-/moment-2.24.0.tgz
.shasum: 0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b

maintainers:
- ichernev <iskren.chernev@gmail.com>
- maggiepint <maggiepint@gmail.com>
- marwahaha <marwahaha@berkeley.edu>
- mj1856 <mj1856@hotmail.com>
- timrwood <washwithcare@gmail.com>

dist-tags:
latest: 2.24.0

published 9 months ago by marwahaha <marwahaha@berkeley.edu>
haoqunjiang commented 4 years ago

That explains why -m npm worked. But no idea why there's still error messages.

Jabark commented 4 years ago

Actually seems to be because vue-cli-version-marker doesn't exist in our artifactory. Will investigate why this is the case.

Jabark commented 4 years ago

So it seems our virtual repo goes to get packages from the remote when you run npm install, but not upon npm info.

haoqunjiang commented 4 years ago

Partially fixed in v4.0.5. Reopen because the current fix in the PR does not fully resolve this issue. We need to implement a fallback mechanism to initiate HTTP requests directly to the official registry.