Preact-cli: npm install failing

Created on 17 Oct 2017  路  10Comments  路  Source: preactjs/preact-cli


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

What is the current behavior?
sudo npm install -g preact-cli fails with the following output:

/usr/local/bin/preact -> /usr/local/lib/node_modules/preact-cli/lib/index.js

> [email protected] postinstall /usr/local/lib/node_modules/preact-cli/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> [email protected] postinstall /usr/local/lib/node_modules/preact-cli/node_modules/preact
> node -e "console.log('\u001b[35m\u001b[1mLove Preact? You can now donate to our open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/preact/donate\u001b[0m')"

Love Preact? You can now donate to our open collective:
 > https://opencollective.com/preact/donate

> [email protected] postinstall /usr/local/lib/node_modules/preact-cli/node_modules/simplehttp2server
> node lib/install.js

/usr/local/lib/node_modules/preact-cli/node_modules/each-async/node_modules/onetime/index.js:15
                throw new Error(fnName + ' can only be called once.');
                ^

Error: callback() can only be called once.
    at onetime (/usr/local/lib/node_modules/preact-cli/node_modules/each-async/node_modules/onetime/index.js:15:11)
    at /usr/local/lib/node_modules/preact-cli/node_modules/download/index.js:156:5
    at ConcatStream.<anonymous> (/usr/local/lib/node_modules/preact-cli/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:110:20)
    at ConcatStream.emit (events.js:207:7)
    at finishMaybe (/usr/local/lib/node_modules/preact-cli/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:607:14)
    at endWritable (/usr/local/lib/node_modules/preact-cli/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:615:3)
    at ConcatStream.Writable.end (/usr/local/lib/node_modules/preact-cli/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:571:41)
    at DuplexWrapper.onend (/usr/local/lib/node_modules/preact-cli/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js:570:10)
    at Object.onceWrapper (events.js:314:30)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/preact-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rakesh/.npm/_logs/2017-10-17T13_43_02_875Z-debug.log

If the current behavior is a bug, please provide the steps to reproduce.
sudo npm install -g preact-cli

What is the expected behavior?
npm install should install preact-cli

If this is a feature request, what is motivation or use case for changing the behavior?
NA

Please mention other relevant information.

  • node version: v8.2.1
  • npm version: 5.5.1
  • Operating system: Ubuntu
discussion duplicate

Most helpful comment

I had this error and I simply uninstalled npm and node globally.
Then i installed nvm from https://github.com/creationix/nvm
then

  1. nvm install node
  2. npm install preact-cli -g
    Voila! everything worked in a single go.

All 10 comments

I also tried npm cache clear --force to ensure that this wasn't some npm caching issue, but that didn't help any.

@rakeshpai I had the same problem. Try with older node version, eg 6.6.0 works

I'm having this problem too but on node 8.5.0, npm 5.5.1 and macOs 10.12.6.

Using yarn instead of npm worked for me.

Please try the suggestion here: https://github.com/developit/preact-cli/issues/424#issuecomment-341988315

@lukeed chowning those directories didn't fix it for me, unfortunately. Still unable to install preact-cli. :( This does smell like an npm-related issue, though.

I had this error and I simply uninstalled npm and node globally.
Then i installed nvm from https://github.com/creationix/nvm
then

  1. nvm install node
  2. npm install preact-cli -g
    Voila! everything worked in a single go.

That probably moves the global dir to the user folder as well

@rakeshpai can you try https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-two-change-npms-default-directory ?

I tried fixing permission ones and then I have reinstall ubuntu. I have somehow bricked it. I found it better then other choices.

I've installed node using n (so I'm doing option 1 from https://docs.npmjs.com/getting-started/fixing-npm-permissions), and am also seeing this issue.

Going option 2 (npm config set prefix '~/.npm-global') results in an EACCESS error:

~$ npm install -g preact-cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

Setting permissions as described in this comment finally fixed the after an hour of mucking around :-/

Faced same issue on Mac os Sierra.
Changed node version to 6.6.0 and then it worked.

$ npm install -g n
$ n 6.6.0

Was this page helpful?
0 / 5 - 0 ratings