parcel build error: plugin is not a function
Asked Answered
P

4

8

I am trying to build a simple web project

project structure like this

-src
--index.html
--index.js
--style.css
package.json
yarn.lock

I installed parcel-bundler with this

yarn global add parcel-bundler

And I run the parcel build command

parcel build src/index.html

But error has occurred followed by this log

D:\playground\js\sample>parcel build src/index.html
×  D:\playground\js\sample\src\style.css:undefined:undefined: plugin is not a function
    at LazyResult.run (C:\Users\pc\AppData\Roaming\nvm\v15.14.0\node_modules\parcel-bundler\node_modules\postcss\lib\lazy-result.js:288:14)
    at LazyResult.asyncTick (C:\Users\pc\AppData\Roaming\nvm\v15.14.0\node_modules\parcel-bundler\node_modules\postcss\lib\lazy-result.js:212:26)
    at C:\Users\pc\AppData\Roaming\nvm\v15.14.0\node_modules\parcel-bundler\node_modules\postcss\lib\lazy-result.js:254:14 
    at new Promise (<anonymous>)
    at LazyResult.async (C:\Users\pc\AppData\Roaming\nvm\v15.14.0\node_modules\parcel-bundler\node_modules\postcss\lib\lazy-result.js:250:23)
    at LazyResult.then (C:\Users\pc\AppData\Roaming\nvm\v15.14.0\node_modules\parcel-bundler\node_modules\postcss\lib\lazy-result.js:131:17)

I'm just following the instruction of parcel's official docs

I cannot find a solution

please help me

Primer answered 13/4, 2021 at 5:39 Comment(0)
P
3

Problem solved: parcel-bundler is deprecated. Use 'parcel' not 'parcel-bundler'

Primer answered 13/4, 2021 at 10:1 Comment(3)
Not according to the official website? parceljs.org/getting_started.htmlMaterial
@Material npmjs.com/package/parcel-bundler It's deprecated... not the first time the documentation has been a pain point for me. Starting to regret trying to use parcel ngl.Electroscope
See my answer below. Some of us can't (though would love to) use Parcel 2 yet, because they've refused to support Vue 2 SFCs, which again are not upgradable to Vue 3 due to dependencies...Sievert
S
16

Try --no-minify

Why is the accepted answer, "throw out the baby with the bathwater?"

parcel-bundler does still work, but instead of fixing what's broken, it's been abandoned for Parcel 2, which DOES NOT support Vue 2 SFCs.

Building a Rails 6/Vue 2 app and converting to parcel from webpack(er), so Parcel 2 is not an option for me. (Demanding people upgrade, and then not providing an upgrade path or decent docs, reminds me too much of webpack!)

parcel build ./app/packs/entrypoints/*.js --no-minify

This disables minification, which at least eliminates this particular error for me.

Sievert answered 10/8, 2021 at 19:54 Comment(1)
...thanks for this. Useful not least because parcel v2 has issues of its own! (...and I want to publish without spending a day figuring out the changes since last time).Mashhad
P
3

Problem solved: parcel-bundler is deprecated. Use 'parcel' not 'parcel-bundler'

Primer answered 13/4, 2021 at 10:1 Comment(3)
Not according to the official website? parceljs.org/getting_started.htmlMaterial
@Material npmjs.com/package/parcel-bundler It's deprecated... not the first time the documentation has been a pain point for me. Starting to regret trying to use parcel ngl.Electroscope
See my answer below. Some of us can't (though would love to) use Parcel 2 yet, because they've refused to support Vue 2 SFCs, which again are not upgradable to Vue 3 due to dependencies...Sievert
A
0

I had the same problem ("C:\Programming\color-picker\src\css\styles.css:undefined:undefined: plugin is not a function") But this problem occurred only after installation "parcel-plugin-handlebars-precompile": "^1.0.2" package. When uninstalled it the parcel build bandle all as should. With parcel-plugin-handlebars-precompile package the "--no-minify" help, but not build "-min" files.

Assault answered 18/4 at 15:43 Comment(0)
S
-1

package.json If you have preset the scripts...

  "scripts": {
    "start": "parcel index.html",
    "dev": "parcel index.html",
    "build": "parcel build index.html"
  },

...simply run

npm run build

otherwise use this syntax:

npm run build index.html

Replace index.html to whatever file you want to build, but make sure it is the same type of file.

Semifinalist answered 17/6, 2021 at 13:59 Comment(1)
when used parcel build index.html had this error, but configured in package.json as said worked.Scoria

© 2022 - 2024 — McMap. All rights reserved.