'Getting cannot use import statement outside a module while running npm script
I am using npm and installed "autoprefixer" package and added this script
"prefix:css":"postcss --use autoprefixer -b 'last 10 versions'
style/stylesheet.comp.css -o style/style.prefix.css"
to the package.json, but when I am trying to run it, I am getting the following error
getting this error SyntaxError: Cannot use import statement outside a module at Module._compile (internal/modules/cjs/loader.js:895:18) at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) at Module.load (internal/modules/cjs/loader.js:815:32) at Function.Module._load (internal/modules/cjs/loader.js:727:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) at internal/main/run_main_module.js:17:11
Solution 1:[1]
import is a keyword not a function so it has a different syntax. See: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/import Use const autoprefixer = require('autoprefixer');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VladoS |
