Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

[WIP] Windows Support #63

Closed
wants to merge 46 commits into from

Conversation

bennygenel
Copy link
Collaborator

Created PR to better track down changes from #27

So far nothing changed too much.

  • Added cross-env for easier cross-platform development
  • Tried to find all path related issues and solved them with using path.join (from @AWolf81 fix)
  • Added .cmd to commands to make sure they run correctly
  • Added set VARIABLE_NAME & commad pattern for commands that require env variables
  • Changed projects' directory path for windows. %USERPROFILE%\Documents is -IMO- much better place for Windows. This can change if decided of course.
  • Added command to find available ports for Windows.

ISSUES:

  • After running eject on a create-react-app project I got an error. I'm not sure why. Any help is appreciated.
Uncaught TypeError: Cannot read property 'logs' of undefined
    at Proxy.draftState (tasks.reducer.js:154)
    at produceProxy (immer.module.js:256)
    at produce (immer.module.js:517)
    at ./src/reducers/tasks.reducer.js.__webpack_exports__.a (tasks.reducer.js:153)
    at combination (redux.js:435)
    at computeNextEntry (instrument.js:138)
    at recomputeStates (instrument.js:172)
    at instrument.js:554
    at Object.dispatch (redux.js:213)
    at dispatch (instrument.js:603)
    at action (import-project.middleware.js:20)
    at action (dependency.middleware.js:82)
    at Socket.child.stdout.on.data (task.middleware.js:167)
    at emitOne (events.js:116)
    at Socket.emit (events.js:211)
    at addChunk (_stream_readable.js:263)
    at readableAddChunk (_stream_readable.js:250)
    at Socket.Readable.push (_stream_readable.js:208)
    at Pipe.onread (net.js:594)
  • gatsby project can be created successfully but dev server is not starting due to an error. It's not related to the command running. I run the command manually and got the error again. Might be related to my setup or an issue with the starter package.

TODOS:

Any todos can go here...

icarlossz and others added 7 commits July 15, 2018 01:24
Adding initial color tu Button for solve a problem with the colors in dark mode of macOs Mojave.
also change repository type from string to {type: ..., url: ...} object found in package.json and update the reducer to return an object with empty values instead of an empty string
Delete {' '} in the parent component.
scripts/start.js Outdated
// Maybe some env variable like `isWin` can be passed to the procces for easy use???
const command = /^win/.test(process.platform)
? `set ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} && electron .`
: `ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} electron .`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ternary could be avoided by passing the environment variable to exec (I believe you can pass an option object which can have an env key.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ternary could be avoided by passing the environment variable to exec (I believe you can pass an option object which can have an env key.

So there is indeed an option to specify env, but there appears to be a bug with Electron where not only are the values not passed, but it messes a bunch of stuff up (commands like ls or pwd fail). Discussion here.

At least, that was my experience with spawn. Given that, though, I'm happy to just have a ternary here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshwcomeau Added a bounty on your SO question. Maybe we can get an answer for this issue there since the Github issue doesn't have any traction.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks a bunch for that! We got an answer that fixes the issue 🎉

I'm super not-clear how this will work on Windows, though. Essentially there are two proposed solutions:

  • Use the env utility instead of calling npm directly. I'm gonna guess that env is a linux/macOS exclusive utility, so that one probably won't work?
  • Supply the process.env.PATH to the command as an environment variable, to forward the current environment. Is PATH a thing on Windows?

That said, this may not even be an issue on Windows (the Electron bug with env might be MacOS only). And this is all a tangent anyway; the underlying issue is mostly about avoiding shell: true, for #25. So I'm fine if we handle this issue elsewhere.

{
encoding: 'utf8',
}
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on macOS? If not, it should be behind a conditional.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++, I think it should look something like:

const homedir = isWin
  ? getWindowsDocumentsPath()
  : os.homedir();

And then getWindowsDocumentsPath would hold the child process and subsequent data munging.

@joshwcomeau
Copy link
Owner

This is looking really good. Thanks so much for your work on this!

The first issue you describe, from task.reducer.js... I'm happy to provide more context, although the issue is a bit befuddling to me as well.

When a project is created, it parses the package.json to find scripts and creates a task object for each one. So a project might be stored in redux like this:

const project = {
  id: 'some-project',
  ...projectSpecificFields,
  tasks: [
    {
      id: 'some-project-start',
      projectId: 'some-project',
      command: 'react-scripts start',
      ...otherTaskFields,
      logs: [],
    }
  ],

Whenever the terminal prints to stdout, the RECEIVE_DATA_FROM_TASK_EXECUTION action is fired, so that we can show that output to the user. The action sends a task object, and then we use that object to find the corresponding task in the state.

When the project is ejected, the eject script is deleted (since it's a 1-time operation). So it seems like what's happening is that the eject task continues to log after the package.json has been updated and that change has been propagated to the redux store.

So I doubt this is truly a windows issue, it sounds like it should be broken for Mac, but the async series of events just happens to work.

To fix it, I would just do this, in task.reducer.js:

    case RECEIVE_DATA_FROM_TASK_EXECUTION: {
      const { task, text, isError, logId } = action;

      if (task.name === 'eject' && !state[task.id]) {
        // When ejecting a CRA project, the `eject` task is removed from the
        // project, since it's a 1-time operation.
        // TODO: We should avoid sending this action, we don't need to capture
        // output for a deleted task
        return state;
      }

it's not the most glamorous solution, but I feel confident that it's safe, and it's something we can address later on.

For the second issue you found, for Gatsby dev server... if I understand, you get exactly the same error when you try to create and run a Gatsby project through the CLI, so it's not necessarily a Guppy issue? If so, I think it's fine to punt on this for now. I'm gonna set up a Windows VM and give this a test. We can open an issue with the Gatsby folks if necessary :)

Thanks again for your work on this, lemme know if I can do anything else to help!

scripts/start.js Outdated
// Maybe some env variable like `isWin` can be passed to the procces for easy use???
const command = /^win/.test(process.platform)
? `set ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} && electron .`
: `ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} electron .`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ternary could be avoided by passing the environment variable to exec (I believe you can pass an option object which can have an env key.

So there is indeed an option to specify env, but there appears to be a bug with Electron where not only are the values not passed, but it messes a bunch of stuff up (commands like ls or pwd fail). Discussion here.

At least, that was my experience with spawn. Given that, though, I'm happy to just have a ternary here :)

// For Windows Support
// Windows sends code 1 (I guess its because we foce kill??)
const successfullCode = isWin ? 1 : 0;
const wasSuccessful = code === successfullCode || code === null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think the issue here is that we lose the ability to detect true failures from false ones; if the task crashes, it would still display "Task Completed" for Windows.

That said, I don't see an easy solution to the problem, it doesn't look like taskkill supports specifying the exit code, and the current architecture means there's no clear way to communicate.

I don't think this is a showstopper; if we can get everything else working on Windows, we can deal with fixing this issue in a subsequent PR (likely by rearchitecting it so that ABORT_TASK handles this directly, instead of using the child-process listeners as an event bus)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think following up state of the process together with a custom redux variable might be beneficial. We can check if the termination was triggered with the switch or the process ended unexpectedly.

I don't know how much of this can be implemented but there can be lots of different informative states. For example rather than just having Running/Idle/Failed we can maybe have Started/Running/Stopping/Stopped/Idle/Failed/Ended Unexpectedly. Since Guppy targets new users, being more informative IMO a great approach.

const wasSuccessful = code === 0 || code === null;
// For Windows Support
// Windows sends code 1 (I guess its because we foce kill??)
const successfullCode = isWin ? 1 : 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: typo, should be successfulCode (only 1 l)

switch (projectType) {
case 'create-react-app':
return [`PORT=${port} npm`, 'run', task.name];
// For Windows Support
command = isWin ? `set PORT=${port} && npm` : `PORT=${port} npm`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not urgent, but I think it'd be neat if we had a helper method, like formatCommandForPlatform, that looked like:

command = formatCommandForPlatform('npm`, { PORT: port });

That way, the whole set prefix (and even the whole prefixing with env variables) wouldn't need to be understood by devs making changes to any part of the code that starts commands.

Feel free to just add a TODO though, I can tackle this in a subsequent PR :)

{
encoding: 'utf8',
}
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++, I think it should look something like:

const homedir = isWin
  ? getWindowsDocumentsPath()
  : os.homedir();

And then getWindowsDocumentsPath would hold the child process and subsequent data munging.

}
);
// prettier-ignore
const winDocumentsPath = winDocumentsRegRecord.split(' ')[winDocumentsRegRecord.split(' ').length - 1].replace('%USERPROFILE%\\', '').replace(/\s/g, '');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know how consistent windows registry formats are between versions of windows? Would this work from Windows 7 through to Windows 10, for example?

IIRC registry stuff tends not to change much, so I believe it's safe, but I haven't used Windows in over a decade 😅so my info is a bit rusty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it a little bit. Initially split was creating bunch of empty values, that is why I replaced bunch of spaces. With single space split it should work in prior windows versions too. I'm going to try it on Win7 soon.

@@ -11,6 +11,9 @@ import type { ProjectType } from '../types';

const fs = window.require('fs');
const childProcess = window.require('child_process');
const path = window.require('path');
const os = window.require('os');
const isWin = /^win/.test(os.platform());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be great to add a services/platform.services.js file that would export:

  • isWin, this quick check
  • getWindowsHomeDir, mentioned above
  • formatCommandForPlatform also mentioned above.

This is super non-urgent, I'm happy to go in after this merges and do it myself :) just mentioning it in case you're up for it (and so that I don't forget)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved isWin and getWindowsDir to platform.services.js. I was going to also propose a complete formatCommad service but I thought it's not really just for windows support so I think it should be in a separate PR. Using a global service function to get the command can benefit from future library additions like next. Doesn't require to change things on different files for example.

// For Windows Support
// To support cross platform with slashes and escapes
// Taken from https://github.com/AWolf81/guppy/commit/b2434d907d0c2c2585006d82ef14523a974de6a0
const projectPath = path.join(parentPath, id);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻good catch @AWolf81

// Finds if the specified port is in use
const command = /^win/.test(os.platform())
? `netstat -aon | find "${port}"`
: `lsof -i :${port}`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Glad to see an equivalent exists (looks like it goes all the way back to Vista too, nice)

@bennygenel
Copy link
Collaborator Author

@joshwcomeau First of all No Problem. And Second of all Thank you for the great project. I'm happy to help.

I want to do that formatCommandForPlatform but I think there should be a settlement on how to approach this for future proof things. I'll be happy to hear what you have in mind for this.

Copy link
Owner

@joshwcomeau joshwcomeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennygenel went through and the latest changes look good!

One thing I haven't seen dealt with in this PR yet is the issue outlined in #25 - we're using echo right now to hack around the fact that childProcess tasks are uni-directional in terms of communication, but we need to accept the prompt for the CRA eject script.

Here's the line in question.

It seems like this wasn't an issue after all? Since you've mentioned being able to eject projects (you get an error, but it happens after the prompt is confirmed).


I want to do that formatCommandForPlatform but I think there should be a settlement on how to approach this for future proof things. I'll be happy to hear what you have in mind for this.

Good question - AFAIK, commands work the same way on MacOS and Linux, so really I think this method could just look like:

const formatCommandForPlatform = (command, environmentVars) => {
  // Create a string like `PORT=4545 HI=5`
  // Could also use Object.values but then Flow will complain x_x
  const envVarString = Object.keys(environmentVars)
    .map(key => `${key}=${environmentVars[key]}`
    .join(' ');

  return isWin
    ? `set ${envVarString} ${command}`
    : `${envVarString} {command}`;
}

It's entirely possible that this is not a future-proofed solution, but I think that's OK, since it's self-contained; the API (as in, the arguments and the return type) shouldn't change if we determine that we need to distinguish between Mac/Linux, since the platform info is available globally.

But yeah, I don't have strong opinions here, so feel free to push back if you have a different idea!


I somehow keep running out of time, so I haven't been able to run this in a VM and test Gatsby yet. Sorry for the delay. I'll try and squeeze it in this evening (I got a VM downloaded, but not yet installed/configured)

scripts/start.js Outdated
// Maybe some env variable like `isWin` can be passed to the procces for easy use???
const command = /^win/.test(process.platform)
? `set ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} && electron .`
: `ELECTRON_START_URL=http://localhost:${DEFAULT_PORT} electron .`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks a bunch for that! We got an answer that fixes the issue 🎉

I'm super not-clear how this will work on Windows, though. Essentially there are two proposed solutions:

  • Use the env utility instead of calling npm directly. I'm gonna guess that env is a linux/macOS exclusive utility, so that one probably won't work?
  • Supply the process.env.PATH to the command as an environment variable, to forward the current environment. Is PATH a thing on Windows?

That said, this may not even be an issue on Windows (the Electron bug with env might be MacOS only). And this is all a tangent anyway; the underlying issue is mostly about avoiding shell: true, for #25. So I'm fine if we handle this issue elsewhere.

@joshwcomeau
Copy link
Owner

@bennygenel I just sent an invitation to become a collaborator on this repo :) I really appreciate the work you've done so far on adding Windows support, + being involved in discussions on other issues.

This is still a super new project so the conventions are still being established, but my current thinking is that collaborators can take a more active role in triaging/closing issues and reviewing/merging PRs (I think for the time being I'd like to retain control over accepting/rejecting any change with UI implications, but feel free to approve and merge PRs that are logic-only and relatively small). Please just make sure that myself or another collaborator has approved your own code before merging it :)

And of course, this doesn't come with any additional expectation on my part, in terms of workload or commitment. Feel free to do as much or as little as you'd like.

I'm in the middle of installing a Windows VM so I hope to be able to test this stuff soon!

* Tests for dependencies reducer

* replace toMatchShapshot with toMatchInlineSnapshot, update jest
@joshwcomeau
Copy link
Owner

Hi @bennygenel

Awesome, sounds like you're making good progress!

For the formatCommandForPlatform idea, I think both of our ideas can work in tandem :) I think there's value in creating a generic utility function that just formats commands for different platforms, something we could imagine using in a different product altogether. But there's also value in having a different function that handles any additional tweaks needed for the different commands, and uses the generic utility to execute them. Unless you think that some scripts might need tweaks beyond setting environment variables? Like maybe the generic utility won't work because there's too much variety?

But yeah, I think this problem, while interesting, isn't pressing. That can be revisited in the future, for now we can punt on it and not bother with formatCommandForPlatform. Bigger fish to fry :)


Adding node_modules/.bin to the PATH seems like a solid strategy!

For the NPX issue, I wonder if we should just do npm run X instead? NPX is a new util and maybe it's too bleeding-edge.


So, I got my windows VM set up, installed Git and Node and VS Code. When I tried to install the Guppy dependencies, though, I got an error:

18 verbose stack TypeError: Cannot read property 'match' of undefined
18 verbose stack     at tarballToVersion (C:\Program Files\nodejs\node_modules\npm\lib\install\inflate-shrinkwrap.js:87:20)
18 verbose stack     at inflatableChild (C:\Program Files\nodejs\node_modules\npm\lib\install\inflate-shrinkwrap.js:99:22)
18 verbose stack     at BB.each (C:\Program Files\nodejs\node_modules\npm\lib\install\inflate-shrinkwrap.js:55:12)
18 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
18 verbose stack     at Object.gotValue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\reduce.js:155:18)
18 verbose stack     at Object.gotAccum (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\reduce.js:144:25)
18 verbose stack     at Object.tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
18 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
18 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
18 verbose stack     at Promise._settlePromiseCtx (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:606:10)
18 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:138:12)
18 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
18 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
18 verbose stack     at runCallback (timers.js:696:18)
18 verbose stack     at tryOnImmediate (timers.js:667:5)
18 verbose stack     at processImmediate (timers.js:649:5)
19 verbose cwd C:\Users\Josh\Documents\work\guppy

I haven't tried to debug this at all yet, but I thought I'd ask and see if this was something you ran into? If not, don't worry about it, I'll investigate more.

@AWolf81
Copy link
Collaborator

AWolf81 commented Jul 19, 2018

@joshwcomeau have you tried to delete node_modules folder and lockfile? Your error message is also mentioned here.
Not sure why this happens and I haven't had the issue but maybe the delete helps.

superhawk610 and others added 17 commits July 21, 2018 09:35
* Add support for highlighting results

* Use DOMParser instead of dangerouslySetInnerHTML and modify highlight styles

* Better styling for spacing, and add more comments

* Wrap part.value in <span> to keep spacing

* Changes to PR to complete review

- Move CustomHighlight to its own component
- Move safeEscapeString into its own utility function
- Don't run the highlight on the package name
A few changes to the contribution docs:

- Rearrange so that "Sending a Pull Request" is closer to the top
- Add a "most important" blurb in the intro
- Add a "Collaborators" section
Add icon instructions. Reorganize dev docs
…joshwcomeau#82)

* Fix html display in dependency search, and styling tweaks for results

* Hide 'load more' on disabled, display as props for ExternalLink

* Set default display prop to inline-block, remove curly braces for string prop
* Add issue templates

Create two templates: one for Bug reports, one for Feature requests.

* Replace multiple issue templates with 1. Add PR template

* Update environment info

* Add HTML comments
* add license and code of conduct
- updated readme to reflect these changes

* update license format, add license to package.json
…into windows-support

	modified:   scripts/start.js
	modified:   src/middlewares/task.middleware.js
@joshwcomeau
Copy link
Owner

Yay, I got my local environment running, and was able to give this a try. Building a project worked flawlessly!!

I did hit an error once I tried running the dev server, after creating a new create-react-app app:

Error: Failed to replace env in config: ${APPDATA}
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:415:13
    at String.replace ()
    at envReplace (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:411:12)
    at parseField (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:389:7)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:330:24
    at Array.forEach ()
    at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:328:23)
    at ConfigChain.addString (C:\Program Files\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
    at Conf. (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:316:10)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:76:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach ()
    at Conf. (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13)
    at Conf.f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at Conf.emit (events.js:182:13)
    at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:335:10)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:472:27)
Error: Failed to replace env in config: ${APPDATA}
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:415:13
    at String.replace ()
    at envReplace (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:411:12)
    at parseField (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:389:7)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:330:24
    at Array.forEach ()
    at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:328:23)
    at ConfigChain.addString (C:\Program Files\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
    at Conf. (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:316:10)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:76:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach ()
    at Conf. (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13)
    at Conf.f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at Conf.emit (events.js:182:13)
    at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:335:10)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:472:27)

Let me know if I can provide any other info!

@AWolf81
Copy link
Collaborator

AWolf81 commented Jul 26, 2018

@joshwcomeau I also had that issue yesterday but I couldn't find the location in code where it uses ${APPDATA}.

I'll have to check what the method npm.config.get('json') is doing. It looks like the problem is inside of the get method or it's because it fails inside of npm.config as npm.config seems undefined.

@superhawk610
Copy link
Collaborator

superhawk610 commented Jul 26, 2018

@joshwcomeau @AWolf81 what's the output of

# Git Bash
echo $APPDATA

# cmd
echo %APPDATA%

from within the shell you're using to run Guppy? It should output something like

C:\Users\aaron\AppData\Roaming

At first glance it seems like this error is resulting from getPathForPlatform in platform.services.js, where remote.app.getPath('appData') attempts to substitute the environment variable APPDATA but can't find any value.

@bennygenel
Copy link
Collaborator Author

@superhawk610 @AWolf81 @joshwcomeau The error is because of npm not getting the config file as you assumed. I got the error and added the getPathForPlatform. Adding Roaming\npm folder to the path solved it on my end but I guess it is not a good solution for everyone. I am going to try to solve the problem when I get some time this weekend. Until then if anyone figures out the problem please feel free to add to the PR.

@joshwcomeau
Copy link
Owner

@superhawk610 @AWolf81 @joshwcomeau The error is because of npm not getting the config file as you assumed. I got the error and added the getPathForPlatform. Adding Roaming\npm folder to the path solved it on my end but I guess it is not a good solution for everyone. I am going to try to solve the problem when I get some time this weekend. Until then if anyone figures out the problem please feel free to add to the PR.

Speaking with @bennygenel on Gitter, he says that this is only an issue with NPM, not with Yarn.

If it proves too troubling, maybe we should just tackle #35 first, moving to use Yarn. There are a bunch of other reasons to move to Yarn, as well.

I mentioned in Gitter, but my schedule for the next 3 weeks is such that I can't spare much time to work on Guppy (pretty much only participating in discussions like these). If anyone wants to tackle this in the meantime, that'd be awesome 🙏 but otherwise I can have it at the top of my list when my schedule frees up.

@AWolf81 AWolf81 mentioned this pull request Aug 11, 2018
@superhawk610
Copy link
Collaborator

Closed via #125.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.