[vuejs/vue-cli]vue create 创建项目文件缺失

2024-04-30 509 views
3
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"

} }


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

回答

7

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

3

控制台的输出,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`

9

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

3

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

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

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

2

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 选项,就会导致这些依赖都无法成功安装。

9

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

2

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