gpt4 book ai didi

javascript - 如何安装 Node 模块@babel/plugin-transform-class-properties?

转载 作者:搜寻专家 更新时间:2023-10-31 22:40:28 24 4
gpt4 key购买 nike

我一直在按照 https://github.com/babel/babelify 的说明进行操作一路上我遇到了一个错误。我运行以下代码行:

browserify script.js -o bundle.js -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] --plugins [ @babel/plugin-transform-class-properties ] ]

终端产生以下错误信息:

Error: Cannot find module '@babel/plugin-transform-class-properties' from '/path/to/file' while parsing file: /path/to/file/circle-graph-2.js

我的 package.json 文件是

{
"name": "robert",
"version": "1.0.0",
"description": "This is the third step of my first attempt to learn canvas. I want to improve a piece a made a few weeks ago about the division of [occupations](http://nbremer.github.io/occupations/). The D3.js version has so many DOM elements due to all the small bar charts that it is very slow. Therefore, I hope that a canvas version might improve things",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"babel": {
"presets": [
"es2015",
"react",
"transform-class-properties"
]
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.1.6",
"babel-core": "^6.26.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babelify": "^10.0.0"
}
}

当我在终端中尝试以下行时,它说找不到包:

npm install --save-dev @babel/plugin-transform-class-properties

如何解决此错误消息?

最佳答案

由于您使用的是 Babel 7(基于您的 "@babel/core": "^7.1.6" 条目),我认为您正在寻找 npm install --save-dev @babel/plugin-proposal-class-properties这是 Babel 7 插件的新版本。请注意名称从“plugin-transform-class-properties”更改为“babel-plugin-proposal-class-properties”。

这是 intentionally done by Babel让人们更加了解 TC39 流程中的功能。

如果您实际上仍在使用 Babel 6(很难判断,因为您的 package.json 中有 Babel 7 和 Babel 6 条目,@Morty 的评论就是您所需要的。

关于javascript - 如何安装 Node 模块@babel/plugin-transform-class-properties?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53529394/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com