在 Windows 上运行更漂亮 [英] Run prettier on windows

查看:37
本文介绍了在 Windows 上运行更漂亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 package.json 中的脚本中添加 prettier.

I want to add prettier into scripts in package.json.

阅读文档,建议使用 cli

Reading at the docs, it suggests doing the following using the cli

In practice, this may look something like:

prettier --single-quote --trailing-comma es5 --write "{app,__{tests,mocks}__}/**/*.js"

它适用于 mac/ubuntu 但在 windows 上收到以下错误消息.

It works on mac / ubuntu but getting the following error message on windows.

[error] No matching files. Patterns tried: 'src/*.js' !**/node_modules/** !./node_modules/**
error Command failed with exit code 2.

推荐答案

对于 Windows,您必须转义 "package.json 将如下所示:

For Windows you have to escape the ", in the package.json will look like this:

"scripts": {
  "prettier": "prettier --single-quote --trailing-comma es5 --write \"{app,__{tests,mocks}__}/**/*.js\"",
},

这篇关于在 Windows 上运行更漂亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆