windows-installer: electron-winstaller only gives the error "the path specified, the file name or both are too long."

When creating the installer, it always gives the same error:

C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp>npm run setup

> infinityapp@0.0.25 setup C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp
> node build.js --force

creating windows installer
Error: Failed with exit code: 1
Output:
Tentando construir o pacote de 'infinityapp.nuspec'.
O caminho especificado, o nome do arquivo ou ambos sao muito longos. O nome de arquivo totalmente qualificado deve ter menos de 260 caracteres e o nome do diret�rio menos de 248 caracteres.

    at ChildProcess.proc.on.code (C:\Users\xDeltaFox\Desktop\Desktop\Programing\JavaScript\InfinityApp\node_modules\electron-winstaller\lib\spawn-promise.js:62:16)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! infinityapp@0.0.25 setup: `node build.js --force`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the infinityapp@0.0.25 setup 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\xDeltaFox\AppData\Roaming\npm-cache\_logs\2017-12-24T13_22_37_506Z-debug.log

I do not know what to do anymore, can anyone help me?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 11
  • Comments: 18 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed this by adding the following line to my package.json:

  "config": {
    "forge": {
      "packagerConfig": {
        "asar": true
      },

The error message says it all: Trying to build the 'infinityapp.nuspec' package. The specified path, the file name, or both are too long. The fully qualified file name must be less than 260 characters and the directory name less than 248 characters. The project is nested in too many folders, making the file path length exceed the limit of allowed characters, which is 260. This was a limitation with Windows, but was removed in Windows 10, but you had to enable the removal of this limit (https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows).

Solution Move your project folder closer to the root directory so that the absolute path to your project does not exceed 260 characters

EDIT: Also ensure where you are attempting to save your output does not exceed the character limit.

@alexanderturinske I am also seeing this issue today. And my deepest project path goes max to 65 characters.

@SujitSingh move the project to the root folder works for me, also i found another solution if you are using electron-packager just set the flag --asar

I fixed this by adding the following line to my package.json:

  "config": {
    "forge": {
      "packagerConfig": {
        "asar": true
      },

Where in package.json do I add this?

I have expanded paths enabled in my registry… Is there an option to force disable this check?

@jegj yes, you are correct. Installer from an asar format file works perfectly(in my other project). But in my case, I am running a local server inside the app 😆. So, I need the folder structure to serve static files.

@alexanderturinske, below are options which I am using -

const rootPath = path.join('./');   // C:\Demo_Tool\   <-- Root path
const outPath = path.join(rootPath, 'widget_builds');

const settings = {
  appDirectory: path.join(outPath, 'demo-tool-win32'),  // also tried names with underscore(_) and without hyphen(-).
  outputDirectory: path.join(outPath, 'windows-installer'), // C:\Demo_Tool\widget_builds\windows-installer
  noMsi: true,
  authors: 'Sujit',
  exe: 'demo-tool.exe',
};

After approximately 15-20 mins, the command generates following errors.

> demo-tool@0.2.0 create-installer-win C:\Demo_Tool
> node src/createInstaller.js

Well, sometimes you are not so lucky: Failed with exit code: 4294967295
Output:
System.AggregateException: One or more errors occurred. ---> System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.InternalGetDirectoryName(String path)
   at Squirrel.ReleasePackage.<>c__DisplayClass14_0.<extractZipWithEscaping>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Squirrel.ReleasePackage.CreateReleasePackage(String outputFile, String packagesRootDir, Func`2 releaseNotesProcessor, Action`1 contentsPostProcessHook)
   at Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String setupIcon, Boolean generateMsi, String frameworkVersion, Boolean generateDeltas)
   at Squirrel.Update.Program.executeCommandLine(String[] args)
   at Squirrel.Update.Program.main(String[] args)
   at Squirrel.Update.Program.Main(String[] args)
---> (Inner Exception #0) System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.InternalGetDirectoryName(String path)
   at Squirrel.ReleasePackage.<>c__DisplayClass14_0.<extractZipWithEscaping>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---