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

npm init egg --type=simple初始化失败(提示:安装 create-egg@latest 失败,错误代码:1),想问下这个问题怎么解决? #3916

Closed
mosicong opened this issue Aug 29, 2019 · 11 comments

Comments

@mosicong
Copy link

What happens?

按照官方文档初始化egg项目失败
$ npm init egg --type=simple bug

npm ERR! code ENOLOCAL
npm ERR! Could not install from "Files\nodejs\node_cache_npx\14516" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Program Files\nodejs\node_cache_logs\2019-08-29T06_34_38_294Z-debug.log
安装 create-egg@latest 失败,错误代码:1

最小可复现仓库

请使用 npm init egg --type=simple bug 创建,并上传到你的 GitHub 仓库

复现步骤,错误日志以及相关配置

错误日志
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'create-egg@latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\Program',
1 verbose cli 'Files\nodejs\node_cache\_npx\14516',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose npm-session e3854aec37858c34
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Files\nodejs\node_cache_npx\14516 Could not install from "Files\nodejs\node_cache_npx\14516" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/create-egg 1527ms (from cache)
9 silly pacote tag manifest for create-egg@latest fetched in 1548ms
10 timing stage:rollbackFailedOptional Completed in 1ms
11 timing stage:runTopLevelLifecycles Completed in 1559ms
12 verbose stack Error: ENOENT: no such file or directory, open 'D:\mosc\30days\MyProject\egg-example1\Files\nodejs\node_cache_npx\14516\package.json'
13 verbose cwd D:\mosc\30days\MyProject\egg-example1
14 verbose Windows_NT 10.0.17134
15 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "create-egg@latest" "--global" "--prefix" "C:\Program" "Files\nodejs\node_cache\_npx\14516" "--loglevel" "error" "--json"
16 verbose node v10.16.3
17 verbose npm v6.9.0
18 error code ENOLOCAL
19 error Could not install from "Files\nodejs\node_cache_npx\14516" as it does not contain a package.json file.
20 verbose exit [ 1, true ]

相关环境信息

  • 操作系统:win 10
  • Node 版本:v10.16.3
    -** Npm版本:6.9.0
  • Egg 版本
@mosicong
Copy link
Author

image
image

@mosicong mosicong changed the title 安装 create-egg@latest 失败,错误代码:1 安装 create-egg@latest 失败,错误代码:1,想问下这个问题怎么解决? Aug 29, 2019
@mosicong mosicong changed the title 安装 create-egg@latest 失败,错误代码:1,想问下这个问题怎么解决? npm init egg --type=simple初始化失败(提示:安装 create-egg@latest 失败,错误代码:1),想问下这个问题怎么解决? Aug 29, 2019
@atian25
Copy link
Member

atian25 commented Aug 30, 2019

感觉是你的 npm 的问题,试着删除 node_cache_npx 目录,然后升级下 npm 版本看看吧

@mosicong
Copy link
Author

有试过完全卸载nodejs和npm,之后重装,不过好像没有作用

@mosicong
Copy link
Author

image
这个是我的node_cache目录路径,是不是因为路径有空格?

@atian25
Copy link
Member

atian25 commented Aug 30, 2019

7 silly fetchPackageMetaData error for file:Files\nodejs\node_cache_npx\14516 Could not install

这里来看是 Files 前面被截断了,这一块是 npm 的内部逻辑了,不确定是不是npm 在 win 的 bug。

你可以先用:

npm install egg-init -g
egg-init --type=simple 

@atian25 atian25 closed this as completed Aug 30, 2019
@mosicong
Copy link
Author

嗯嗯,目前用的是这种方式,谢谢解答

@xygzyf2008
Copy link

我跟你遇到同样的问题了:
image
看了下log,原因是node安装的路径下有空格导致的:
image
执行下面2条命令,指定下路径就行了:
npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"
image

@liugezhou
Copy link

image
我这是等待了五分钟,控制台没有蠕动

@mosicong
Copy link
Author

image
我这是等待了五分钟,控制台没有蠕动

npm install egg-init -g
egg-init --type=simple
试下这样的初始化方式

@ruibaby
Copy link

ruibaby commented May 17, 2021

同样的问题,使用 yarn 可以成功:

yarn create egg --type=simple

@atian25
Copy link
Member

atian25 commented Jul 9, 2021

image
我这是等待了五分钟,控制台没有蠕动

很明显你连接 npm 太慢了,要切源。

npm init egg -r china

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

No branches or pull requests

5 participants