Repository navigation
Closed
Labels
Description
Not sure there's much nodeenv can do here as the paths are really deep
Here's some of the errors I've seen from this:
$ nodeenv C:/Temp/123456789012345678901234567890/nenv
* Install prebuilt node (8.1.3) ..... done.
Invalid switch - "Temp".
Invalid switch - "Temp".
Error: Failed to create nodejs.exe link
* Install npm.js (latest) ... Traceback (most recent call last):
File "c:\python27\Lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\Anthony\Desktop\git\pre-commit\venv\Scripts\nodeenv.exe\__main__.py", line 9, in <module>
File "c:\users\anthony\desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 1028, in main
create_environment(env_dir, opt)
File "c:\users\anthony\desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 872, in create_environment
instfunc(env_dir, src_dir, opt)
File "c:\users\anthony\desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 745, in install_npm_win
shutil.copytree(join(src_dir, npm_ver), node_modules_path)
File "c:\python27\Lib\shutil.py", line 208, in copytree
raise Error, errors
shutil.Error: [('C:\\Temp\\123456789012345678901234567890\\nenv\\src\\npm-latest\\node_modules\\pacote\\node_modules\\ma
ke-fetch-happen\\node_modules\\http-proxy-agent\\node_modules\\agent-base\\node_modules\\es6-promisify\\node_modules\\es
6-promise\\lib\\es6-promise\\promise', 'C:/Temp/123456789012345678901234567890/nenv\\Scripts\\node_modules\\npm\\node_mo
dules\\pacote\\node_modules\\make-fetch-happen\\node_modules\\http-proxy-agent\\node_modules\\agent-base\\node_modules\\
es6-promisify\\node_modules\\es6-promise\\lib\\es6-promise\\promise', "[Error 206] The filename or extension is too long
: 'C:/Temp/123456789012345678901234567890/nenv\\\\Scripts\\\\node_modules\\\\npm\\\\node_modules\\\\pacote\\\\node_modul
es\\\\make-fetch-happen\\\\node_modules\\\\http-proxy-agent\\\\node_modules\\\\agent-base\\\\node_modules\\\\es6-promisi
fy\\\\node_modules\\\\es6-promise\\\\lib\\\\es6-promise\\\\promise'"), ('C:\\Temp\\123456789012345678901234567890\\nenv\
\src\\npm-latest\\node_modules\\pacote\\node_modules\\make-fetch-happen\\node_modules\\https-proxy-agent\\node_modules\\
agent-base\\node_modules\\es6-promisify\\node_modules\\es6-promise\\lib\\es6-promise\\promise', 'C:/Temp/123456789012345
678901234567890/nenv\\Scripts\\node_modules\\npm\\node_modules\\pacote\\node_modules\\make-fetch-happen\\node_modules\\h
ttps-proxy-agent\\node_modules\\agent-base\\node_modules\\es6-promisify\\node_modules\\es6-promise\\lib\\es6-promise\\pr
omise', "[Error 206] The filename or extension is too long: 'C:/Temp/123456789012345678901234567890/nenv\\\\Scripts\\\\n
ode_modules\\\\npm\\\\node_modules\\\\pacote\\\\node_modules\\\\make-fetch-happen\\\\node_modules\\\\https-proxy-agent\\
\\node_modules\\\\agent-base\\\\node_modules\\\\es6-promisify\\\\node_modules\\\\es6-promise\\\\lib\\\\es6-promise\\\\pr
omise'"), ('C:\\Temp\\123456789012345678901234567890\\nenv\\src\\npm-latest\\node_modules\\pacote\\node_modules\\make-fe
tch-happen\\node_modules\\socks-proxy-agent\\node_modules\\agent-base\\node_modules\\es6-promisify\\node_modules\\es6-pr
omise\\lib\\es6-promise\\promise', 'C:/Temp/123456789012345678901234567890/nenv\\Scripts\\node_modules\\npm\\node_module
s\\pacote\\node_modules\\make-fetch-happen\\node_modules\\socks-proxy-agent\\node_modules\\agent-base\\node_modules\\es6
-promisify\\node_modules\\es6-promise\\lib\\es6-promise\\promise', "[Error 206] The filename or extension is too long: '
C:/Temp/123456789012345678901234567890/nenv\\\\Scripts\\\\node_modules\\\\npm\\\\node_modules\\\\pacote\\\\node_modules\
\\\make-fetch-happen\\\\node_modules\\\\socks-proxy-agent\\\\node_modules\\\\agent-base\\\\node_modules\\\\es6-promisify
\\\\node_modules\\\\es6-promise\\\\lib\\\\es6-promise\\\\promise'")]
E CalledProcessError: Command: ('C:\\Users\\Anthony\\Desktop\\git\\pre-commit\\venv\\Scripts\\python.exe', '-m
', 'nodeenv', '--prebuilt', 'C:\\Temp\\a\\t0\\0\\.pre-commit\\repo3ejck1\\node_env-default')
E Return code: 1
E Expected return code: 0
E Output: (none)
E Errors:
E * Install prebuilt node (8.1.3) ..... done.
E You do not have sufficient privilege to perform this operation.
E You do not have sufficient privilege to perform this operation.
E Error: Failed to create nodejs.exe link
E * Install npm.js (latest) ... Traceback (most recent call last):
E File "c:\python27\Lib\runpy.py", line 162, in _run_module_as_main
E "__main__", fname, loader, pkg_name)
E File "c:\python27\Lib\runpy.py", line 72, in _run_code
E exec code in run_globals
E File "C:\Users\Anthony\Desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 1277, in <modul
e>
E main()
E File "C:\Users\Anthony\Desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 1028, in main
E create_environment(env_dir, opt)
E File "C:\Users\Anthony\Desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 872, in create_
environment
E instfunc(env_dir, src_dir, opt)
E File "C:\Users\Anthony\Desktop\git\pre-commit\venv\lib\site-packages\nodeenv.py", line 742, in install
_npm_win
E zipf.extractall(src_dir)
E File "c:\python27\Lib\zipfile.py", line 1053, in extractall
E self.extract(zipinfo, path, pwd)
E File "c:\python27\Lib\zipfile.py", line 1041, in extract
E return self._extract_member(member, path, pwd)
E File "c:\python27\Lib\zipfile.py", line 1092, in _extract_member
E os.mkdir(targetpath)
E WindowsError: [Error 206] The filename or extension is too long: 'C:\\Temp\\a\\t0\\0\\.pre-commit\\repo3
ejck1\\node_env-default\\src\\npm-latest\\node_modules\\pacote\\node_modules\\make-fetch-happen\\node_modules\\http-prox
y-agent\\node_modules\\agent-base\\node_modules\\es6-promisify\\node_modules\\es6-promise\\lib\\es6-promise\\promise'
Activity
fredericrous commentedon Jul 26, 2017
I got the same error on windows10. As you said @asottile, I don't have a clue of what could be done to bypass this problem... except running the command from root directory and crossing fingers
asottile commentedon Jan 12, 2018
A workaround for this problem: pre-commit/pre-commit#200 (comment)
ekalinin commentedon Sep 19, 2026
This looks resolved for the default Windows flow, so I'm closing it.
bfe13b3 ("Use prebuilt windows zip which contains npm", Jan 2019, released in 1.3.4).
One case is still affected. With an explicit
--with-npm,install_npm_winunpackshttps://github.com/npm/cli/archive/v<ver>.zip, whose longest entry in v11.6.2 is 207 chars (arborist test fixtures with intentionally nestednode_modules). That drops the env dir budget to ~47 chars during extraction intosrcand to ~37 after the copy intoScripts\node_modules\npm. That code path is already broken for an unrelated reason (#310: it copies the npm/cli source repo rather than the released package) and it also 404s with the default--npm=latest, since the URL becomes.../archive/vlatest.zip. Switching it to the registry tarball would fix the package layout and the path length at once, so that part belongs with #310 rather than here.The other errors quoted in the report (
Invalid switch - "Temp",You do not have sufficient privilege,Error: Failed to create nodejs.exe link) are unrelated to path length and are still present. They come fromcallit(['mklink', shim_nodejs, 'node.exe'], True, True):mklinkis a cmd builtin invoked withshell=True, so a forward-slash env path is parsed as a switch, and creating the link needs admin rights or Developer Mode. Worth a separate issue.