require(...) is not a function
Scrum opened this issue · comments
I've faced with a similar in AlexWayfer/flame-cli#57 (I'm trying to replace SCSS with PostCSS completely, so it's not quite this PR, but based on it).
> postcss assets/styles/ -d public/styles/ --base assets/styles/ --ext=css
TypeError: require(...) is not a function
at Object.<anonymous> (/home/alex/Projects/ruby/test/foo_bar/postcss.config.js:3:40)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19)
at module.exports (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/import-fresh@3.2.2/node_modules/import-fresh/index.js:32:59)
at loadJs (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/loaders.js:16:18)
at Explorer.loadFileContent (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/Explorer.js:84:32)
at Explorer.createCosmiconfigResult (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/Explorer.js:89:36)
My configuration:
// postcss.config.js
module.exports = {
plugins: [
// there can be more, but it's reproducible only with this package
require('postcss-at-rules-variables')({ atRules: ['media'] })
]
}
package.json
:
"dependencies": {
"@babel/core": "*",
"@babel/plugin-transform-object-assign": "*",
"@babel/preset-env": "*",
"@rollup/plugin-babel": "*",
"@rollup/plugin-commonjs": "*",
"@rollup/plugin-json": "*",
"@rollup/plugin-node-resolve": "*",
"autoprefixer": "*",
"postcss-at-rules-variables": "*",
"postcss-cli": "*",
"postcss-flexbugs-fixes": "*",
"postcss-mixins": "*",
"postcss-nested": "*",
"promise-polyfill": "*",
"rollup": "*",
"sass": "*",
"simplify-js": "*",
"whatwg-fetch": "*"
},
...
"scripts": {
"build:styles": "postcss assets/styles/ -d public/styles/ --base assets/styles/ --ext=css",
...
}
With version lock like this:
"postcss-at-rules-variables": "^0.1.0",
there is no such error.
Originally posted by @AlexWayfer in #204 (comment)