Add a new "type": "module" property to the package.json file
时间: 2023-10-02 11:11:23 浏览: 114
To add a new "type": "module" property to the package.json file, follow these steps:
1. Open the root directory of your project in a text editor.
2. Locate the package.json file in the root directory.
3. Add a new property "type": "module" to the package.json file, like this:
```
{
"name": "my-project",
"version": "1.0.0",
"description": "My project description",
"type": "module",
"dependencies": {
"my-dependency": "^1.0.0"
}
}
```
4. Save the changes to the package.json file.
Once you have added the "type": "module" property to the package.json file, you can use ES modules in your project without having to use the ".mjs" file extension. You can simply import modules using the standard import syntax.
阅读全文