Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: node.getIterator is not a function #1414

Closed
LP1994 opened this issue Sep 17, 2020 · 6 comments
Closed

TypeError: node.getIterator is not a function #1414

LP1994 opened this issue Sep 17, 2020 · 6 comments

Comments

@LP1994
Copy link

LP1994 commented Sep 17, 2020

node: 14.11.0;
npm: 6.14.8;
operating system: Windows 10;
postcss: 8.0.5;
postcss-less: 3.1.4;

Error description:
ERROR in ./src/styles/less/basic/Basic.less
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: node.getIterator is not a function
at LazyResult.visitTick (G:\SNWS\sn-micro-front-web-project-template\node_modules\postcss\lib\lazy-result.js:470:33)
at LazyResult.runAsync (G:\SNWS\sn-micro-front-web-project-template\node_modules\postcss\lib\lazy-result.js:357:30)
at async Object.loader (G:\SNWS\sn-micro-front-web-project-template\node_modules\postcss-loader\dist\index.js:94:14)
@ ./src/tplEJS/pages/AuditLogIndex.ejs (./node_modules/html-webpack-plugin/lib/loader.js!./src/tplEJS/pages/AuditLogIndex.ejs) 83:10-42

step:
When I use the following configuration, an error will be reported: TypeError: node.getIterator is not a function.
{
test: /.less$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name]_[sha512:contenthash:hex:6].css',
outputPath: './styles/',
emitFile: true,
esModule: false,
}
},
{
loader: 'extract-loader',
},
{
loader: 'css-loader',
options: {
url: true,
import: true,
importLoaders: 2,
esModule: false,
},
},

    // If you comment out the "postcss-loader" below, you won't get an error(TypeError: node.getIterator is not a function).
    {
        loader: 'postcss-loader',
        options: {
            execute: false,
            sourceMap: false,
            postcssOptions: {
                syntax: require( 'postcss-syntax' )( {
                    css: require( 'postcss-safe-parser' ),
                    sass: require( 'postcss-sass' ),
                    scss: require( 'postcss-scss' ),
                    less: require( 'postcss-less' ),
                } ),
            },
        },
    },

    {
        loader: 'less-loader',
        options: {
            lessOptions: {
                math: 'strict-legacy',
                strictUnits: true,
                noIeCompat: true,
            },
        },
    },
],
sideEffects: true,

}

explain:
When processing ".less" files, if "postcss-loader" is not used, no error will be reported and it can be successfully compiled. If "postcss-loader" is used, an error will be reported. Moreover, the above configuration will not report an error in postcss 7. X, but it will be reported if it is updated to postcss 8. X.

@LP1994
Copy link
Author

LP1994 commented Sep 17, 2020

I live in the East eight international time zone, so if you have any questions, you may not be able to reply in time. Please forgive me for the inconvenience.

@ai
Copy link
Member

ai commented Sep 17, 2020

Seems like postcss-less do not support PostCSS 8. Downgrade other PostCSS modules.

I will create an issue in postcss-less tomorrow.

@LP1994
Copy link
Author

LP1994 commented Sep 17, 2020

Thank you for your timely reply!!! At first, I thought that it might be the "postcss less" problem. However, the code reported "postcss", so I came here to submit the error. Now I will go to "postcss less" to submit this error.

@ai
Copy link
Member

ai commented Sep 17, 2020

Here is a correct issue shellscape/postcss-less#150

@Juraj-Masiar
Copy link

Juraj-Masiar commented Jul 25, 2021

Hello,
I'm having the same issue, but I'm not using less:

        {
          test: /\.css$/,
          use: [
            MiniCssExtractPlugin.loader,
            "css-loader",
            "postcss-loader",    // if I comment out this line, it will work again
          ]
        },

This is the full stack trace:

ERROR in ./src/editor/editor.vue?vue&type=style&index=0&lang=scss& (./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/sass-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./src/editor/editor.vue?vue&type=style&index=0&lang=scss&)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: node.getIterator is not a function
    at LazyResult.visitTick (C:\Users\Juraj\git\addons\PrivateNotes\node_modules\postcss\lib\lazy-result.js:528:33)
    at LazyResult.runAsync (C:\Users\Juraj\git\addons\PrivateNotes\node_modules\postcss\lib\lazy-result.js:408:30)
    at LazyResult.async (C:\Users\Juraj\git\addons\PrivateNotes\node_modules\postcss\lib\lazy-result.js:221:30)
    at LazyResult.then (C:\Users\Juraj\git\addons\PrivateNotes\node_modules\postcss\lib\lazy-result.js:206:17)
 @ ./node_modules/vue-style-loader/index.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/sass-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./src/editor/editor.vue?vue&type=style&index=0&lang=scss& 4:14-328
 @ ./src/editor/editor.vue?vue&type=style&index=0&lang=scss& 1:0-364 1:0-364
 @ ./src/editor/editor.vue 4:0-67
 @ ./src/editor/editor.ts 10:0-34 26:49-55

And my libraries:

"autoprefixer": "^10.3.1",
"html-inline-css-webpack-plugin": "^1.11.1",
"mini-css-extract-plugin": "^2.1.0",
"postcss": "^8.3.6",
"postcss-cli": "^8.3.1",
"postcss-comment": "^2.0.0",
"postcss-load-config": "^3.1.0",
"postcss-loader": "^6.1.1",
"postcss-plugin": "^1.0.0",
"sass": "^1.36.0",
"sass-loader": "^12.1.0",
"style-loader": "^3.2.1",
"vue-loader": "^15.9.6",
"vue-style-loader": "^4.1.3",

I'm trying to migrate to Webpack 5 and this is the last problem I'm facing.
I've tried to downgrade PostCSS from 8 to 7 but then I get a different error from one of the libraries that says:

Error: PostCSS plugin postcss-discard-comments requires PostCSS 8

EDIT:

So I've managed to track down the issue to the "postcss-comment" library which was not updated in 3 years :(

@latel
Copy link

latel commented Apr 12, 2024

postcss-comment

any ideas how to track which library is causing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants