rogeriochaves / npm-force-resolutions

Force npm to install a specific transitive dependency version

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Npm install fails in npm-force-resolutions if there is a space in the user folder

andremarcondesteixeira opened this issue · comments

Here is the error I am getting when running npm install:

Error: EPERM: operation not permitted, mkdir 'C:\Users\Andre'
command not found: npm-force-resolutions
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cad-lite@0.1.0 preinstall: `npx npm-force-resolutions`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cad-lite@0.1.0 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Andre Teixeira\AppData\Roaming\npm-cache\_logs\2020-09-21T13_07_45_868Z-debug.log

Here is the debut log (C:\Users\Andre Teixeira\AppData\Roaming\npm-cache_logs\2020-09-21T13_07_45_868Z-debug.log)

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   'install'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.3
4 verbose npm-session cdb3edcb11d401d1
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall cad-lite@0.1.0
7 info lifecycle cad-lite@0.1.0~preinstall: cad-lite@0.1.0
8 verbose lifecycle cad-lite@0.1.0~preinstall: unsafe-perm in lifecycle true
9 verbose lifecycle cad-lite@0.1.0~preinstall: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\projects\project_x\frontend\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Symantec.cloud\PlatformAgent\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Users\Andre Teixeira\AppData\Local\Microsoft\WindowsApps;C:\Users\Andre Teixeira\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Andre Teixeira\AppData\Roaming\npm;C:\Users\Andre Teixeira\.dotnet\tools
10 verbose lifecycle cad-lite@0.1.0~preinstall: CWD: C:\projects\project_x\frontend
11 silly lifecycle cad-lite@0.1.0~preinstall: Args: [ '/d /s /c', 'npx npm-force-resolutions' ]
12 silly lifecycle cad-lite@0.1.0~preinstall: Returned: code: 1  signal: null
13 info lifecycle cad-lite@0.1.0~preinstall: Failed to exec preinstall script
14 timing stage:rollbackFailedOptional Completed in 1ms
15 timing stage:runTopLevelLifecycles Completed in 1001ms
16 verbose stack Error: cad-lite@0.1.0 preinstall: `npx npm-force-resolutions`
16 verbose stack Exit status 1
16 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
16 verbose stack     at EventEmitter.emit (events.js:315:20)
16 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
16 verbose stack     at ChildProcess.emit (events.js:315:20)
16 verbose stack     at maybeClose (internal/child_process.js:1021:16)
16 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
17 verbose pkgid cad-lite@0.1.0
18 verbose cwd C:\projects\project_x\frontend
19 verbose Windows_NT 10.0.19041
20 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
21 verbose node v12.18.3
22 verbose npm  v6.14.6
23 error code ELIFECYCLE
24 error errno 1
25 error cad-lite@0.1.0 preinstall: `npx npm-force-resolutions`
25 error Exit status 1
26 error Failed at the cad-lite@0.1.0 preinstall script.
26 error This is probably not a problem with npm. There is likely additional logging output above.
27 verbose exit [ 1, true ]

I know it is not an npm preinstall error because if I try running any other command on preinstall, it works well.

A workaround is setting npm cache folder to another place:
npm config set cache C:\tmp\nodejs\npm-cache --global

I am having this issue also...

I am having this issue also...

I tried just about every suggestion I could find and then some. Running npm audit fix did the trick for me.

None of the above resolution worked for me. Any other fix for this?

To anyone experiencing this issue, feel free to try: https://www.npmjs.com/package/force-resolutions

Just change:

"preinstall": "npx npm-force-resolutions"

To:

"preinstall": "npx force-resolutions"

npx force-resolutions does not run when no package-lock.json is detected, and allows the next command inline to be executed as normal. This is useful when installing dependencies for a package that has been already published where package-lock.json is not available.

If this issue persists please send more information to be able to replicate, and afterwards implement and adaptation

Feedback and PR's are welcome