Giter Site home page Giter Site logo

fix-path's Issues

No effect in PATH?

fix-path: v2.0.0
Electron: v1.1.1
Node: v6.2.0
System: Yosemite 10.10.5

code:

const fixPath = require('fix-path');
console.log('PATH before fix:');
console.log(process.env.PATH);
fixPath();
console.log('PATH after fix:');
console.log(process.env.PATH);

logs:

PATH before fix:
/usr/bin:/bin:/usr/sbin:/sbin
PATH after fix:
/usr/bin:/bin:/usr/sbin:/sbin

how to use with require() ?

I tried to import as it is in the readme and got an error.

import fixPath from 'fix-path';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1185:20)
    at Module._compile (node:internal/modules/cjs/loader:1227:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
A JavaScript error occurred in the main process
Uncaught Exception:
/home/pablo/GitHub/electron-test/src/index.js:6
import fixPath from 'fix-path';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1185:20)
    at Module._compile (node:internal/modules/cjs/loader:1227:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

ES Module import error

Environment: Node v14

There is an import error after upgrading to v4.

ERROR: : Must use import to load ES Module.

Screenshot is also attached for reference:
image

Ubuntu Linux Also ?

Hi

This module has been great for our application - many thanks !

We've now got to build a Linux (Ubuntu) version and we're getting a similar path problem. I tried fix-path but it doesn't seem to work on Linux. Are there any plans to extend it out to Linux ?

Thanks

Ian

Path not being fixed

> echo $PATH
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/sbin:/Users/dave/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/deployd/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin

Using Electron 0.30.2:

require('fix-path')()
var dialog = require('dialog')

dialog.showErrorBox("path", process.env.PATH)

screen shot 2015-07-31 at 18 50 39

It works fine on my Macbook Pro but fails to list all the paths on my Macbook Air (as shown above). They are both running Yosemite. I have also reproduced the same issue on a friends Macbook.

Any idea what could be going on here?

ANSI codes appear in process.env.PATH after fix-path

I am using this in my vscode-yo plugin and noticed something strange. I upgraded some dotfiles of today and since then, the plugin wasn't showing any generators anymore. After investigating this, ANSI color codes where added in front of the path.

console.log(process.env.PATH.split(path.delimiter));
//=> [ '/Users/sam/.nvm/versions/node/v4.2.1/bin', '/usr/local/bin', ...]

require('fix-path')();

console.log(process.env.PATH.split(path.delimiter));
//=> [ '\u001b(B\u001b[m/Users/sam/.nvm/versions/node/v4.2.1/bin', '/usr/local/bin', ...]

After some more investigation, it seems that these lines in my dot-files trigger this behaviour.

if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
    export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
    export TERM='xterm-256color';
fi;

If I remove these lines, the ANSI code is not added.

Fix

A simple fix is strip-ansi

require('fix-path')();

console.log(stripAnsi(process.env.PATH).split(path.delimiter));
//=> [ '/Users/sam/.nvm/versions/node/v4.2.1/bin', '/usr/local/bin', ...]

But maybe, this should be fixed somewhere deeper in the chain. After digging into with fix-path does, I came to this line 72 in shell-path/index.js. This is the line that returns the path with the ANSI color codes.

Unexpected token error

I got unexpected token error in fix-path code.

This is the content of fix-path:

'use strict';
module.exports = () => {
    const env = process.env;

    if (process.platform === 'darwin') {
        return env.SHELL || '/bin/bash';
    }

    if (process.platform === 'win32') {
        return env.COMSPEC || 'cmd.exe';
    }

    return env.SHELL || '/bin/sh';
}();

When I removed last () , it didn't give invalid syntax error.

What could be wrong?

I installed nodejs via brew
$ node --version v5.10.1

Webpack warning: Module not found: Error: Can't resolve 'spawn-sync'

WARNING in ./node_modules/shell-env/node_modules/cross-spawn/index.js 30:20-41
Module not found: Error: Can't resolve 'spawn-sync' in '/Volumes/Projects/record/app/node_modules/shell-env/node_modules/cross-spawn'
 @ ./node_modules/shell-env/node_modules/execa/index.js 7:19-41
 @ ./node_modules/shell-env/index.js 3:14-30
 @ ./node_modules/shell-path/index.js 3:17-37
 @ ./node_modules/fix-path/index.js 3:18-39
 @ ./app/main.dev.js 6:0-31 33:2-9

I think it may be the same issue as sindresorhus/shell-env#12

Get $PATH from the real shell

Just an idea:

var exec = require("child_process").execSync;
var userShell = String(exec("/bin/sh -c 'echo $SHELL'")).trim();
process.env.PATH = String(exec(userShell +" -c 'echo $PATH'")).trim();

This should work at least with bash and zsh and possibly other shells that take a -c argument.

Module not found: Can't resolve 'node:os'

fix-path: 4.0.0
electron: 13.2.3
@craco/craco: 6.2.0

Hello, any idea what i'm doing wrong? My app fails to compile after add this package as a dep.

[0] Failed to compile.
[0] 
[0] ./node_modules/default-shell/index.js
[0] Module not found: Can't resolve 'node:os' in '[...]/node_modules/default-shell'

Must use import to load ES Module

Any way to use this with require instead of import?
I tried using multiple variations of require('fix-path') but it won't work.
I'm unable to use import statement outside a module as it breaks all of my require related pieces.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.