npm install -g fails with permission error
See original GitHub issueInstallation has failed for me twice, on machines with different architectures and node/npm versions. I get the same error on each platform:
`# npm i -g api-spec-converter /usr/local/bin/api-spec-converter -> /usr/local/lib/node_modules/api-spec-converter/bin/api-spec converter
jsonpath@0.2.12 postinstall /usr/local/lib/node_modules/api-spec-converter/node_modules/jsonpath node lib/aesprim.js > generated/aesprim-browser.js sh: generated/aesprim-browser.js: Permission denied npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! jsonpath@0.2.12 postinstall:
node lib/aesprim.js > generated/aesprim-browser.jsnpm ERR! Exit status 1 npm ERR! npm ERR! Failed at the jsonpath@0.2.12 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ โ โ Update available 5.3.0 โ 5.4.2 โ โ Run npm i -g npm to update โ โ โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2017-09-21T06_47_16_083Z-debug.log`
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:22

Top Related StackOverflow Question
I can and do install global packages all the time. Just ahead of this install, I globally installed โswagger-to-graphql,โ which is the point of this exercise; the files Iโm converting need to be in Swagger v2 format, but they are currently in Swagger v1.
It failed to work with sudo, giving the same permissions error as it did with full root access.
However, while researching, I found a thread where the following syntax was explicated, and it installs just fine this way:
sudo npm install -g api-spec-converter --unsafe-perm=true --allow-rootThis works in Linux Slackware64-current. Iโm off to the races. Obviously, it may not work for everyone on all architectures, so the jsonpath folks should probably be made aware of the issue.
it works for me ๐
sudo npm install -g artillery --unsafe-perm=true --allow-root