简体   繁体   English

使用experimental-json-modules时,ESLint不适用于json导入

[英]ESLint not working for json import when using experimental-json-modules

I have the following in my package.json...我的 package.json 中有以下内容...

"lint:fix": "node --experimental-json-modules ./node_modules/.bin/eslint **/*.mjs --fix"

And the following in my code以及我的代码中的以下内容

import pkgjson from "../package.json" assert { type: 'json' };

But when I run the lint command I see...但是当我运行 lint 命令时,我看到...

1:39  error  Parsing error: Unexpected token assert

How do I use json imports with eslint?如何在 eslint 中使用 json 导入?

Eslint Support of assert {type: "json"} Eslint 支持assert {type: "json"}

Eslint discussion thread Eslint 讨论线程

In the discussion thread you can find several alternatives to solve this problem在讨论线程中,您可以找到解决此问题的几种替代方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 节点 16:是否仍需要 --experimental-json-modules CLI 标志? - Node 16: is the --experimental-json-modules CLI flag still required? 没有 --experimental-modules 标志,使用导入的 Node.js 不起作用 - Node.js using import is not working without the --experimental-modules flag 如何使用 ECMA 模块在 nodejs 中导入.json 文件? - How can I import .json files in nodejs using ECMA Modules? pm2 不适用于实验模块标志 - pm2 not working with experimental-modules flag 设置了 --experimental-modules 的“不能在模块外使用导入语句” - "Cannot use import statement outside a module" with --experimental-modules set 从 package.json 作为脚本运行时出现 ESLint 错误 - ESLint errors when running as script from package.json 如何将 json 导入 nodejs v14+ 中的 ES 模块? - How to import json into ES modules in nodejs v14+? 初始化时出现 Eslint 错误! 意外令牌 { 在 JSON 中的位置 139 运行 'eslint --init' 以符合 airbnb 标准 - Eslint error upon initialization! Unexpected token { in JSON at position 139 when running 'eslint --init' for airbnb standards 使用NODEJS基于模块打破Swagger JSON - Breaking Swagger JSON based on the modules using NODEJS 使用节点时如何修复 eslint 错误:导入 Node.js 内置模块时的协议 - How to fix eslint error when using the node: protocol when importing Node.js builtin modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM