zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

TypeError: Cannot read property 'get' of undefined if (npm.config.get('json')) #143

Closed jvitoroc closed 6 years ago

jvitoroc commented 6 years ago

Node version: 8.7.0 npm version: 5.4.2

"devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-minify": "^0.2.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-minify": "^0.2.0"
  }

I'm getting the following errors when I run npx minify index.js --out-file index.min.js, but the command works (file is minified)

C:\Users\João Vitor\Documents\uniqual>npx minify index.js --out-file index.min.js
Error: EPERM: operation not permitted, mkdir 'C:\Users\João'
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:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
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 emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
    at process._fatalException (bootstrap_node.js:374:26)
Install for prefix@latest failed with code 7
C:\Users\João Vitor\Documents\uniqual\node_modules\babel-minify\bin\minify.js

C:\Users\João Vitor\Documents\uniqual>npx minify index.js --out-file index.min.js
Error: EPERM: operation not permitted, mkdir 'C:\Users\João'
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:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
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 emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
    at process._fatalException (bootstrap_node.js:374:26)
Install for prefix@latest failed with code 7
C:\Users\João Vitor\Documents\uniqual\node_modules\babel-minify\bin\minify.js
noelleleigh commented 6 years ago

Looks like a duplicate of #100 , caused by profiles with spaces in them.

zkat commented 6 years ago

Closing as duplicate of #100

arikkfir commented 6 years ago

Pasting my comment from facebook/react#11933 in case it helps others:

I got the same error (in facebook/react#11933) working for me by adding sudo, as such:

sudo npx create-react-app my-app

Note that this might be because my Node.js installation's file-system owner is indeed root rather than my own user - perhaps this is the root cause for this issue?

sarvold commented 5 years ago

I have same issue, it's that Windows has created my user folder with spaces in it too.