yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.4k stars 2.73k forks source link

failed to install amphtml-validator in win10 #4918

Open maple3142 opened 6 years ago

maple3142 commented 6 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? run yarn add amphtml-validator on win10 then cause an error error log:

C:\Users\Administrator\Documents\temp>yarn add amphtml-validator
openssl config failed: error:02001003:system library:fopen:No such process
yarn add v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⠐ amphtml-validator
[-/1] ⠐ waiting...
[-/1] ⠐ waiting...
[-/1] ⠐ waiting...
error C:\Users\Administrator\Documents\temp\node_modules\amphtml-validator: Command failed.
Exit code: 1
Command: \bin\sh -c "exit 0" 2> postinstall.DELETEME && rm postinstall.DELETEME || node postinstall-windows.js
Arguments:
Directory: C:\Users\Administrator\Documents\temp\node_modules\amphtml-validator
Output:
path.js:28
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.join (path.js:489:7)
    at Object.<anonymous> (C:\Users\Administrator\Documents\temp\node_modules\amphtml-validator\postinstall-windows.js:43:10)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)

npm install --save amphtml-validator works on both win10 and bash on windows yarn add amphtml-validator only works on bash on windows

What is the expected behavior? install correctly

Please mention your node.js, yarn and operating system version.

blobcat commented 6 years ago

I was able to work around this issue by defining the NPM_CONFIG_PREFIX environment variable and pointing it at my node installation dir.

For example, if you installed to C:\nodejs: setx NPM_CONFIG_PREFIX C:\nodejs

If you're using nvm for windows this works: setx NPM_CONFIG_PREFIX %NVM_SYMLINK%

Not sure what the root cause is but in this case the amphtml-validator package has a post install script for windows that is supposed to update a global installation if there is one. It uses the NPM_CONFIG_PREFIX var to check if it exists. Seems like windows 10 barfs if the env var isn't there.

alrra commented 6 years ago

@pbakaus ⬆️

pbakaus commented 6 years ago

paging @Gregable, who might know more.

alrra commented 6 years ago

@pbakaus, @Gregable FYI: This is what we are using in the sonarwhal project to work around this issue.