graphql-codegen 不是 运行 配置文件
graphql-codegen not running with config file
在我的 package.json
文件中,我有 运行s graphql-codegen
的脚本条目,但它抱怨 --config
参数无效:
$> yarn gen
yarn run v1.21.1
$ graphql-codegen --config codegen.yml
Error: Unknown argument: config
...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
因为我相信默认文件名是 codegen.yml
,所以我尝试 运行 它没有那个参数,但没有生成任何东西:
$> yarn graphql-codegen
yarn run v1.21.1
$ /home/aaron/projects/my_app/node_modules/.bin/graphql-codegen
Done in 0.17s.
有什么想法吗?
好的,我不确定我做了什么来解决这个问题。我相信我还全局安装了 graphql-codegen
并尝试使用 sudo npm uninstall graphql-codegen
卸载它,这删除了一堆包但可执行文件仍然存在:
$>which graphql-codegen
/usr/bin/graphql-codegen
但是我一时兴起决定 运行 yarn graphql-codegen init
看看 init
是否有效,因为我不记得我是否已经尝试过。我像往常一样得到了设置问题,所以我 ctrl+C
只 运行 yarn graphql-codegen
就成功了!然后我 运行 yarn graphql-codegen --watch
测试它是否采用了选项并且也有效。
如果有人遇到这个问题,希望这些提示对您有所帮助。
对我来说,解决方案是安装@graphql-codegen/cli。
graphql.config.yml
schema: http://localhost:8081/graphql
extensions:
codegen:
generates:
./schema.graphql:
- schema-ast
package.json
{
"codegen": "graphql codegen --config graphql.config.yml"
}
对我来说,这解决了问题
纱线
yarn add -D @graphql-codegen/cli
npm
npm i -D @graphql-codegen/cli
也可能是您安装了 apollo's graphql-codegen package,它还公开了一个名为 graphql-codegen
的二进制文件,它接受参数 schema
和 output
,但不接受 [=13] =].
试一试:rm -rf ./node_modules && npm install
rm http://manpages.ubuntu.com/manpages/trusty/man1/rm.1.html
remove files or directories
-f, --force ignore nonexistent files and arguments, never prompt
-r, -R, --recursive remove directories and their contents recursively
node_modules https://docs.npmjs.com/cli/v7/configuring-npm/folders
You can think of the node_modules folder like a cache
for the external modules that your project depends upon. When you npm
install them, they are downloaded from the web and copied into the
node_modules folder and nodejs is trained to look for them there when
you import them (without a specific path).
npm 安装 https://docs.npmjs.com/cli/install/
This command installs a package and any packages that it depends on.
If the package has a package-lock, or an npm shrinkwrap file, or a
yarn lock file, the installation of dependencies will be driven by
that, respecting the following order of precedence:
- npm-shrinkwrap.json
- package-lock.json
- yarn.lock
在我的 package.json
文件中,我有 运行s graphql-codegen
的脚本条目,但它抱怨 --config
参数无效:
$> yarn gen
yarn run v1.21.1
$ graphql-codegen --config codegen.yml
Error: Unknown argument: config
...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
因为我相信默认文件名是 codegen.yml
,所以我尝试 运行 它没有那个参数,但没有生成任何东西:
$> yarn graphql-codegen
yarn run v1.21.1
$ /home/aaron/projects/my_app/node_modules/.bin/graphql-codegen
Done in 0.17s.
有什么想法吗?
好的,我不确定我做了什么来解决这个问题。我相信我还全局安装了 graphql-codegen
并尝试使用 sudo npm uninstall graphql-codegen
卸载它,这删除了一堆包但可执行文件仍然存在:
$>which graphql-codegen
/usr/bin/graphql-codegen
但是我一时兴起决定 运行 yarn graphql-codegen init
看看 init
是否有效,因为我不记得我是否已经尝试过。我像往常一样得到了设置问题,所以我 ctrl+C
只 运行 yarn graphql-codegen
就成功了!然后我 运行 yarn graphql-codegen --watch
测试它是否采用了选项并且也有效。
如果有人遇到这个问题,希望这些提示对您有所帮助。
对我来说,解决方案是安装@graphql-codegen/cli。
graphql.config.yml
schema: http://localhost:8081/graphql
extensions:
codegen:
generates:
./schema.graphql:
- schema-ast
package.json
{
"codegen": "graphql codegen --config graphql.config.yml"
}
对我来说,这解决了问题
纱线
yarn add -D @graphql-codegen/cli
npm
npm i -D @graphql-codegen/cli
也可能是您安装了 apollo's graphql-codegen package,它还公开了一个名为 graphql-codegen
的二进制文件,它接受参数 schema
和 output
,但不接受 [=13] =].
试一试:rm -rf ./node_modules && npm install
rm http://manpages.ubuntu.com/manpages/trusty/man1/rm.1.html
remove files or directories
-f, --force ignore nonexistent files and arguments, never prompt
-r, -R, --recursive remove directories and their contents recursively
node_modules https://docs.npmjs.com/cli/v7/configuring-npm/folders
You can think of the node_modules folder like a cache for the external modules that your project depends upon. When you npm install them, they are downloaded from the web and copied into the node_modules folder and nodejs is trained to look for them there when you import them (without a specific path).
npm 安装 https://docs.npmjs.com/cli/install/
This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that, respecting the following order of precedence:
- npm-shrinkwrap.json
- package-lock.json
- yarn.lock