最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - This experimental syntax requires enabling one of the following parser plugin(s): 'classPrivateProperties,

programmeradmin1浏览0评论

I'm trying to bundle my javascript files using parcel everything is going ok except that I get this problem when I run npm run start

@parcel/transformer-js: This experimental syntax requires enabling one of the following parser plugin(s): 'classPrivateProperties, classPrivateMethods'

after some googling I found out that I need to install the classPrivateProperties and the classPrivateMethods so I did but the same problem occuring here is my package.json file

{
  "name": "starter",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/plugin-proposal-private-methods": "^7.13.0",
    "@babel/plugin-proposal-private-property-in-object": "^7.13.0",
    "@parcel/optimizer-cssnano": "^2.0.0-nightly.612",
    "@parcel/optimizer-htmlnano": "^2.0.0-nightly.612",
    "@parcel/packager-css": "^2.0.0-nightly.612",
    "@parcel/packager-html": "^2.0.0-nightly.612",
    "@parcel/transformer-css": "^2.0.0-nightly.612",
    "@parcel/transformer-html": "^2.0.0-nightly.612",
    "@parcel/transformer-postcss": "^2.0.0-nightly.612",
    "@parcel/transformer-posthtml": "^2.0.0-nightly.612",
    "@parcel/transformer-sass": "^2.0.0-nightly.612",
    "node": "^15.10.0",
    "parcel": "^2.0.0-beta.1",
    "postcss": "^8.2.6",
    "sass": "^1.26.10"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "fractional": "^1.0.0",
    "regenerator-runtime": "^0.13.7"
  },
  "plugins": [
    "@babel/plugin-proposal-private-methods",
    "@babel/plugin-proposal-private-property-in-object"
  ]
}

thanks for your help

I'm trying to bundle my javascript files using parcel everything is going ok except that I get this problem when I run npm run start

@parcel/transformer-js: This experimental syntax requires enabling one of the following parser plugin(s): 'classPrivateProperties, classPrivateMethods'

after some googling I found out that I need to install the classPrivateProperties and the classPrivateMethods so I did but the same problem occuring here is my package.json file

{
  "name": "starter",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/plugin-proposal-private-methods": "^7.13.0",
    "@babel/plugin-proposal-private-property-in-object": "^7.13.0",
    "@parcel/optimizer-cssnano": "^2.0.0-nightly.612",
    "@parcel/optimizer-htmlnano": "^2.0.0-nightly.612",
    "@parcel/packager-css": "^2.0.0-nightly.612",
    "@parcel/packager-html": "^2.0.0-nightly.612",
    "@parcel/transformer-css": "^2.0.0-nightly.612",
    "@parcel/transformer-html": "^2.0.0-nightly.612",
    "@parcel/transformer-postcss": "^2.0.0-nightly.612",
    "@parcel/transformer-posthtml": "^2.0.0-nightly.612",
    "@parcel/transformer-sass": "^2.0.0-nightly.612",
    "node": "^15.10.0",
    "parcel": "^2.0.0-beta.1",
    "postcss": "^8.2.6",
    "sass": "^1.26.10"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "fractional": "^1.0.0",
    "regenerator-runtime": "^0.13.7"
  },
  "plugins": [
    "@babel/plugin-proposal-private-methods",
    "@babel/plugin-proposal-private-property-in-object"
  ]
}

thanks for your help

Share Improve this question asked Mar 2, 2021 at 12:45 Amine El wereAmine El were 8553 gold badges9 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

If you are talking about Parcel.js, you need to install and configure some Babel plugins, to enable Class Private Properties and Methods:

  1. Install this packages with NPM:

    npm i @babel/plugin-proposal-private-methods @babel/plugin-proposal-class-properties

  2. Create the .babelrc file at the root folder of your project with this:

    {
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-private-methods"
      ]
    }
  1. Run Parcel again.

I solved this problem by installing the plugins and adding a .babelrc configuration file to the root of my project.

{
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-private-methods"
  ]
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论