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

run 'vue init webpack' fail in windows10 #681

Closed
xiejiamiao opened this issue Dec 12, 2017 · 11 comments
Closed

run 'vue init webpack' fail in windows10 #681

xiejiamiao opened this issue Dec 12, 2017 · 11 comments

Comments

@xiejiamiao
Copy link

node version is v8.9.1
npm version is 5.5.1
vue-cli version is 2.9.2

if i initialize a vue project like:

vue init webpack testproject

and follow the prompts to configure, then it show err:

? Project name test
? Project description A Vue.js project
? Author
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm

   vue-cli · Generated "test".


# Installing project dependencies ...
# ========================


events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT
    at _errnoException (util.js:1024:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
@KyleLehtinenDev
Copy link

KyleLehtinenDev commented Dec 12, 2017

Same, failing on OSX 10.11.6.
node version is v8.9.3
npm version is 5.5.1
vue-cli version is 2.9.2

Seemed to just fail on npm install. After doing a manual npm install and checking it out things seem to be working.

@xiejiamiao
Copy link
Author

It work fine on OSX 10.12.6
the node version, npm version, vue-cli version all is same to you
but everything is work fine.

@IcedKnight
Copy link

the same error, node version 7.5.0, newest vue-cli version,

@litong534
Copy link

you can choose 'NO, I will handle that myself' as a workaround

@songhongjiang
Copy link

the same error, node version 7.9.0, newest vue-cli version

@Will233
Copy link

Will233 commented Dec 13, 2017

Should we run npm install for you after the project has been created? (recommended)
choose :NO, I will handle that myself

@xiejiamiao
Copy link
Author

? Should we run `npm install` for you after the project has been created? (recommended)
   Yes, use NPM
   Yes, use Yarn
>  No, I will handle that myself

on this step choose :

> No, I will handle that myself

after the project has been created, run

npm install

as administrator to install dependencies.
after this, run

npm run dev

is work fine

@typistZxd
Copy link

the same error,but it can work after run npm run dev

@lambdakris
Copy link

lambdakris commented Dec 14, 2017

There is also an issue in the npm repo npm/npm#19374 about the same thing.

The issue is that when you provide a name to create a directory, like so

vue init webpack myproject
...

Instead of using the current directory, like so

mkdir myproject
cd myproject
vue init webpack
...

When you then elect to have scaffolding restore your packages (whether through npm or yarn), you are not in the project directory, but above it, so the package install/restore command fails. The workaround works because it skips the package install/restore command. The fix (if you like) would be for vue-cli to change into the directory that it created (when a name is provided) before running the package install/restore command.

@LinusBorg
Copy link
Member

LinusBorg commented Dec 14, 2017

Hi guys,

I'm the one responsible for that new feature of the template (see: vuejs-templates/webpack#1133). I tested in throughly on OS X, and @sudo-suhas did on windows.

However, since we can't test all version combinations of OS's and node/npm, errors can happen, so sorry about that and thanks for your patience.

Immediate solutions/workarounds.

One thing we can immediately improve is the error handling. This error is not "fatal" - all people have to do is run npm install themselves. So I will add a nice error message explaining that to users.

so what's the Problem, really?

As to the original source of the problem, I'm a bit dumbfounded for the moment.

When you then elect to have scaffolding restore your packages (whether through npm or yarn), you are not in the project directory, but above it, so the package install/restore command fails

That would be weird - being in the wrong directory should lead to an error on OSX as well, but doesn't (for me).

I also think I set the cwd for the npm call to the right directory here:

https://github.com/vuejs-templates/webpack/blob/develop/meta.js#L155-L158

Continuing in the right repository

Since this issue is caused by code in the webpack template, not the CLI, have opened an issue there (see: vuejs-templates/webpack#1168) - further discussion should be taking pace there as well.

Therefore I will lock this issue, but keep it open for others with the same problem until it's fixed. It will be closed when the problem is solved in the template repo.

There is also an issue in the npm repo npm/npm#19374 about the same thing.

The problem we are seeing here is very likely our fault, not npm's. That ticket should be closed.

@vuejs vuejs locked and limited conversation to collaborators Dec 14, 2017
@LinusBorg
Copy link
Member

This should be fixed now with vuejs-templates/webpack#1170

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

No branches or pull requests

9 participants