Created
November 2, 2022 17:54
-
-
Save Soul-Master/241d3092f490af5d3cc2a442e91e8e51 to your computer and use it in GitHub Desktop.
Fix Node.js working directory issue in NPM 8.19.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Restore working dir and remove additional argument | |
const originalCwd = process.argv.length >= 3 ? process.argv[2] : ''; | |
if(originalCwd.startsWith('$$')) { | |
process.argv.splice(2, 1); | |
process.chdir(originalCwd.substring(2)); | |
} | |
require('../lib/cli.js')(process) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
GOTO start | |
:find_dp0 | |
SET dp0=%~dp0 | |
EXIT /b | |
:start | |
SETLOCAL | |
CALL :find_dp0 | |
IF EXIST "%dp0%\node.exe" ( | |
SET "_prog=%dp0%\node.exe" | |
) ELSE ( | |
SET "_prog=node" | |
SET PATHEXT=%PATHEXT:;.JS;=;% | |
) | |
:: Pass current dir as last argument to `npm-cli.js` | |
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\node_modules\npm\bin\npm-cli.js" "$$%cd%" %* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment