npm run prefix:css ERR

Viewed 1936

My System confg

OS : Microsoft Windows 10,
code editor : Visual Studio Code   
node version : v10.13.0,
npm version : 6.4.1

following commands npm run start, npm run compile:sass, npm run concat::css are working well.
But npm run prefix:css is throwing error.

I work under two circumstances, the one is able to connect the internet and the other is not.
Yesterday I work it at home which is able to connect the internet.

At first, I did npm install postcss --save-dev.
Then I did npm run prefix:css.
The console threw ERROR.

What's my problem ?
How can I fix the problem.

Strangely, 'postcss.cmd' command isn't made in the 'node_modules.bin' folder.
Other normal commands are made in the the 'node_modules.bin' folder.

  1. my package.json is
{
    "name": "natours",
    "version": "1.0.0",
    "description": "landing page for natours",
    "main": "index.js",
    "scripts": {
        "watch:sass": "node-sass sass/main.scss css/natours.sass -w",
        "devserver": "live-server",
        "start": "npm-run-all --parallel devserver watch:sass",
        "compile:sass": "node-sass sass/main.scss css/natours.comp.css",
        "concat:css": "concat -o css/natours.concat.css css/icon-font.css css/natours.comp.css",
        "prefix:css": "postcss --use autoprefixer -b 'last 10 versions' css/natours.concat.css  -o css/natours.prefix.css",
        "compass:css": "node-sass css/natours.prefix.css css/natours.css --output-style compressd",
        "build:css": "npm-run-all compile:sass concat:css prefix:css compass:css"
    },
    "author": "Jsmile",
    "license": "ISC",
    "dependencies": {
        "save-dev": "^2.0.0"
    },
    "devDependencies": {
        "autoprefixer": "^9.4.4",
        "concat": "^1.0.3",
        "node-sass": "^4.11.0",
        "npm-run-all": "^4.1.5",
        "postcss": "^7.0.8"
    }
}
  1. Here I reproduced the error by following commands
F:\개인\workspace\CSS\css_sass\1-Natours>npm install postcss --save-dev  
npm WARN natours@1.0.0 No repository field.  

+ postcss@7.0.8  
updated 1 package and audited 639 packages in 2.778s  
found 0 vulnerabilities  

F:\개인\workspace\CSS\css_sass\1-Natours>npm run prefix:css  

> natours@1.0.0 prefix:css F:\개인\workspace\CSS\css_sass\1-Natours  
> postcss --use autoprefixer -b 'last 10 versions' css/natours.concat.css  -o css/natours.prefix.css  

'postcss'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.  
npm ERR! code ELIFECYCLE  
npm ERR! errno 1  
npm ERR! natours@1.0.0 prefix:css: `postcss --use autoprefixer -b 'last 10 versions' css/natours.concat.css  -o css/natours.prefix.css`  
npm ERR! Exit status 1  
npm ERR!  
npm ERR! Failed at the natours@1.0.0 prefix:css script.  
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.  

npm ERR! A complete log of this run can be found in:  
npm ERR!     C:\Users\No.1\AppData\Roaming\npm-cache\_logs\2019-01-10T22_37_17_074Z-debug.log
4 Answers
"prefix:css": "postcss --use autoprefixer -b \"last 10 versions\" css/natours.concat.css  -o css/natours.prefix.css"

In Windows OS the below syntax is used:

"prefix:css": "postcss --use autoprefixer -b \"last 10 versions\" css/natours.concat.css  -o css/natours.prefix.css"

The problem is probably with postcss, try using postcss-cli instead.

But surely, running

postcss --use autoprefixer -b 'last 10 versions' css/natours.concat.css -o css/natours.prefix.css

directly in your terminal will work, don't run the script.

Install both:

npm install postcss --save-dev 
npm install postcss-cli --save-dev

then:

npm run prefix:css
Related