Skip to content

path.replace is not a function  #360

Description

@RavinduDharmasena

When I try to to prefix a css using the command postcss --use autoprefixer -b 'last 10 versions' style.concat.css -o css/style.prefix.css, it throws following error.

TypeError: path.replace is not a function                                                                                   
      at module.exports (G:\sass_course_projects\Natours_Media_Queries\node_modules\slash\index.js:10:14)                     
      at Array.map (<anonymous>)                                                                                              
      at G:\sass_course_projects\Natours_Media_Queries\node_modules\postcss-cli\index.js:66:28                            
npm ERR! code ELIFECYCLE                                                                                               
npm ERR! errno 1                                                                                                        
npm ERR! natours@1.0.0 prefix:css: `postcss --use autoprefixer -b 'last 10 versions' style.concat.css -o css/style.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\ACER\AppData\Roaming\npm-cache\_logs\2020-12-03T11_27_52_699Z-debug.log 

given below is the debug log file content

Details
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'prefix:css'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v12.19.0
4 verbose run-script [ 'prefix:css' ]
5 info lifecycle natours@1.0.0~prefix:css: natours@1.0.0
6 verbose lifecycle natours@1.0.0~prefix:css: unsafe-perm in lifecycle true
7 verbose lifecycle natours@1.0.0~prefix:css: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;G:\sass_course_projects\Natours_Media_Queries\node_modules\.bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;G:\xampp_PHP5\php;G:\xampp\php;C:\Users\ACER\AppData\Local\Microsoft\WindowsApps;;C:\Users\ACER\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\ACER\AppData\Roaming\Composer\vendor\bin;C:\Users\ACER\AppData\Roaming\npm
8 verbose lifecycle natours@1.0.0~prefix:css: CWD: G:\sass_course_projects\Natours_Media_Queries
9 silly lifecycle natours@1.0.0~prefix:css: Args: [
9 silly lifecycle   '/d /s /c',
9 silly lifecycle   "postcss --use autoprefixer -b 'last 10 versions' style.concat.css -o css/style.prefix.css"
9 silly lifecycle ]
10 silly lifecycle natours@1.0.0~prefix:css: Returned: code: 1  signal: null
11 info lifecycle natours@1.0.0~prefix:css: Failed to exec prefix:css script
12 verbose stack Error: natours@1.0.0 prefix:css: `postcss --use autoprefixer -b 'last 10 versions' style.concat.css -o css/style.prefix.css`
12 verbose stack Exit status 1
12 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
12 verbose stack     at EventEmitter.emit (events.js:314:20)
12 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
12 verbose stack     at ChildProcess.emit (events.js:314:20)
12 verbose stack     at maybeClose (internal/child_process.js:1021:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
13 verbose pkgid natours@1.0.0
14 verbose cwd G:\sass_course_projects\Natours_Media_Queries
15 verbose Windows_NT 10.0.19042
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "prefix:css"
17 verbose node v12.19.0
18 verbose npm  v6.14.8
19 error code ELIFECYCLE
20 error errno 1
21 error natours@1.0.0 prefix:css: `postcss --use autoprefixer -b 'last 10 versions' style.concat.css -o css/style.prefix.css`
21 error Exit status 1
22 error Failed at the natours@1.0.0 prefix:css script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 1, true ]

Activity

  1. RyanZim commented on Dec 3, 2020

    @RyanZim
    Collaborator

    I cannot reproduce on Linux; so I'll need you to help me debug this.

    If you edit node_modules\postcss-cli\index.js line 64 to read console.warn(input) and run again, what is the output?

    postcss-cli/index.js

    Lines 61 to 67 in 453aaec

    if (argv.watch && !(argv.output || argv.replace || argv.dir)) {
    error('Cannot write to stdout in watch mode')
    }
    if (input && input.length) {
    return globber(input.map(slash), { dot: argv.includeDotfiles })
    }

  2. RavinduDharmasena commented on Dec 3, 2020

    @RavinduDharmasena
    Author

    This is the output that I have got after following your instructions.

    [ 10, "versions'", 'css/style.concat.css' ]
    TypeError: path.replace is not a function
    at module.exports (G:\sass_course_projects\Natours_Media_Queries\node_modules\slash\index.js:10:14)
    at Array.map ()
    at G:\sass_course_projects\Natours_Media_Queries\node_modules\postcss-cli\index.js:66:28
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! natours@1.0.0 prefix:css: postcss --use autoprefixer -b 'last 10 versions' css/style.concat.css -o css/style.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\ACER\AppData\Roaming\npm-cache_logs\2020-12-03T16_10_37_158Z-debug.log

  3. RyanZim commented on Dec 3, 2020

    @RyanZim
    Collaborator

    My bad, I should have seen that from just looking at your initial post. Your problem is that you're using single quotes around last 10 versions. Windows doesn't recognize single quotes as quotes on the command line; using double-quotes should make it work.

    Also, you'll want to delete node_modules and reinstall to undo the changes I requested.

  4. RyanZim commented on Dec 3, 2020

    @RyanZim
    Collaborator

    Note to self: perhaps should cast to string before running through slash to give a more intelligent error message in this case.

  5. RavinduDharmasena commented on Dec 3, 2020

    @RavinduDharmasena
    Author

    It works when I Replaced single quotes with doubles quotes with escape characters as mentioned by you. Thank you so much for the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions