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

Building web component via cli works only once #3662

Open
raibait opened this issue Mar 18, 2019 · 3 comments
Open

Building web component via cli works only once #3662

raibait opened this issue Mar 18, 2019 · 3 comments

Comments

@raibait
Copy link

raibait commented Mar 18, 2019

Version

3.5.0

Environment info

  System:
    OS: macOS 10.14.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
  Binaries:
    Node: 10.15.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 72.0.3626.121
    Firefox: Not Found
    Safari: 12.0.3
  npmGlobalPackages:
    @vue/cli: 3.5.1

Steps to reproduce

On a brand new vue cli project created with vue create I want to run a vue web component bundler. I run npx vue-cli-service build --target wc --name my-element *.vue from src folder and it compiles nicely. After that, every next try ends up with 404error from https://registry.npmjs.org/vue-cli-service.
It runs again after I remove package-lock and node_modules and npm install:
rm -rf node_modules package-lock.json && npm install
What am I doing wrong ?
image

What is expected?

to rebuild web component every time I want it

What is actually happening?

it runs only once, on a clean project and then got error 404 every next time


removing package-lock and node_modules , then 'npm install' helps

@LinusBorg LinusBorg added needs team repro We acknowledged your report and will soon try to reproduce it cannot reproduce We cannot reproduce the problem with the given information. More env information needed. and removed needs team repro We acknowledged your report and will soon try to reproduce it labels Mar 19, 2019
@LinusBorg
Copy link
Member

Can't reproduce this. Can you share a repository to reproduce it better maybe?

@raibait
Copy link
Author

raibait commented Mar 21, 2019

Ofcourse, every time :). Check out my repo: https://github.com/raibait/vue-web-cpnt-bug

@LinusBorg LinusBorg added needs team repro We acknowledged your report and will soon try to reproduce it and removed cannot reproduce We cannot reproduce the problem with the given information. More env information needed. labels Mar 21, 2019
@haoqunjiang
Copy link
Member

The root cause here:

The npx command was run in the src/ directory.
And the default cache folder is node_modules/.cache (relative to process.cwd()). So after running this command, a src/node_modules/.cache folder was created.

So when the npx command was run for the second time, it found a node_modules directory in the current working directory and stopped looking up in the upper-level directory. Of course, npx couldn't find the vue-cli-service command in the current directory, so it tried to download from the npm registry.
But as there's no corresponding package name for this command, a 404 would be returned.

There's little we can do for this issue. Maybe adding a warning when vue-cli-service is called in a directory without package.json?

@haoqunjiang haoqunjiang added enhancement scope: cli-service build and removed needs team repro We acknowledged your report and will soon try to reproduce it labels Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants