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

vue create 创建项目文件缺失 #4926

Closed
x710894881 opened this issue Dec 4, 2019 · 9 comments
Closed

vue create 创建项目文件缺失 #4926

x710894881 opened this issue Dec 4, 2019 · 9 comments

Comments

@x710894881
Copy link

Version

4.0.5

Environment info

Environment Info:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.11.3/bin/npm
  Browsers:
    Chrome: 78.0.3904.108
    Firefox: 70.0.1
    Safari: 13.0.3
  npmGlobalPackages:
    @vue/cli: 4.0.5

Steps to reproduce

1、vue create hello-world

2、

? Please pick a preset: Manually select features

? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter

? Use history mode for router? (Requires proper server setup for index fallback in production) No

? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Stylus

? Pick a linter / formatter config: Standard

? Pick additional lint features: (Press to select, to toggle all, to invert selection)Lint on s
ave

? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json

? Save this as a preset for future projects? No

3、过程中无报错和异常

4、cd hello-world

What is expected?

无文件缺失和npm run serve 启动服务。

What is actually happening?

hello-world文件夹下只包含package.json、package-lock.json和README.md,其中package.json内容为:

{

"name": "hello-world",

"version": "0.1.0",

"private": true,

"devDependencies": {

"@vue/cli-plugin-babel": "^4.1.0",

"@vue/cli-plugin-eslint": "^4.1.0",

"@vue/cli-plugin-router": "^4.1.0",

"@vue/cli-plugin-vuex": "^4.1.0",

"@vue/cli-service": "^4.1.0"

}
}


不知道是什么原因导致的这个问题,还请给出问题排查方向或者解决办法,谢谢。

@x710894881
Copy link
Author

也尝试切换了node的版本和vue-cli的版本,均是一样的情况。

@haoqunjiang
Copy link
Member

3、过程中无报错和异常

请问下控制台输出是什么?
node_modules 有生成吗?

看症状大概是在执行这段代码时中止了

// install plugins
stopSpinner()
log(`⚙ Installing CLI plugins. This might take a while...`)
log()
this.emit('creation', { event: 'plugins-install' })
if (isTestOrDebug && !process.env.VUE_CLI_TEST_DO_INSTALL_PLUGIN) {
// in development, avoid installation process
await require('./util/setupDevProject')(context)
} else {
await pm.install()
}
// run generator
log(`🚀 Invoking generators...`)
this.emit('creation', { event: 'invoking-generators' })
const plugins = await this.resolvePlugins(preset.plugins)
const generator = new Generator(context, {
pkg,
plugins,
afterInvokeCbs,
afterAnyInvokeCbs
})
await generator.generate({
extractConfigFiles: preset.useConfigFiles
})

可能是因为什么原因导致插件依赖没能成功安装上

@x710894881
Copy link
Author

控制台的输出,node_modules 没有生成,就只生成了package.json、package-lock.json和README.md 这三个文件,
`Vue CLI v4.1.1
✨ Creating project in /vue/hello-world.
🗃 Initializing git repository...
⚙ Installing CLI plugins. This might take a while...

up to date in 15.277s
🚀 Invoking generators...
📦 Installing additional dependencies...

up to date in 4.567s
⚓ Running completion hooks...

📄 Generating README.md...

🎉 Successfully created project hello-world.
👉 Get started with the following commands:

$ cd hello-world
$ npm run serve`

@haoqunjiang
Copy link
Member

能否提供一下你的 ~/.npmrc 文件内容?
如果设置了 package-lock-only=true 的话是会出现这种情况的

@x710894881
Copy link
Author

~/.npmrc 文件内容如下,谢谢

registry=https://registry.npm.taobao.org/  
production=true  
home=https://npm.taobao.org  

@x710894881
Copy link
Author

感谢 @sodatea ,我自己尝试把 production=true 改成 production=false 就可以,求教一下导致的原因,谢谢

@haoqunjiang
Copy link
Member

https://docs.npmjs.com/cli/install#description

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

这个配置一般是用于上线运行的 Node.js 项目的。
而对于需要打包的前端项目,所有的开发工具都是作为 devDependencies 出现的,如果配置了 production 选项,就会导致这些依赖都无法成功安装。

@wmo123
Copy link

wmo123 commented Oct 28, 2020

为什么我在命令行运~/.npmrc会报:command not found

@wmo123
Copy link

wmo123 commented Oct 28, 2020

我同样把 .npmrc 更改为 registry=https://registry.npm.taobao.org/ global=true production=false 没有解决问题 @sodatea @x710894881

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