Failed at the #angular/cli#8.3.19 postinstall script - node.js

Hi I can't install the angular cli with npm install -g #angular/cli#8.3.19.
I keep getting this :
> node ./bin/postinstall/script.js
module.js:549
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v13.0.1/lib/node_modules/#angular/cli/bin/postinstall/script.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#8.3.19 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#8.3.19 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! /root/.npm/_logs/2019-11-26T00_10_33_515Z-debug.log
Node version : 13.0.1
Npm version : 6.13.1
Ubuntu version : 18.04.2
I also tried without specifying a CLI version.

I tried with this command that I found online :
npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
And it worked.

Try to run with sudo npm. On Ubuntu, you need to run with root permission. It depends on how you install node.
sudo npm install -g #angular/cli#8.3.19
On the other hand, try to install node 12 and LTS versions to have a more secure version.
Hope it helps

Try clean your npm cache before npm cache clean or npm cache verify then npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root

Steps I followed
Downgrade node version using nvm to v12.3.0
Remove ng folder from /root/.nvm/versions/node/v12.3.0/bin
Again do npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
and it worked

Related

Can't install 'node-sass' on Ubuntu 20

I use webpack 4, sass, pug and bemto. Module on windows worked normal, but on Ubuntu:
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! node-sass#4.14.1 postinstall: `node scripts/build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-sass#4.14.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I tried enter command:
sudo npm install -g --unsafe-perm node-sass
>
(node:8310) [DEP0139] DeprecationWarning: Calling process.umask() with no arguments is prone to race conditions and is a potential security vulnerability.
(Use `node --trace-deprecation ...` to show where the warning was created)
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/usr/local/bin/node-sass -> /usr/local/lib/node_modules/node-sass/bin/node-sass
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2725/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> node-sass#4.14.1 install /usr/local/lib/node_modules/node-sass
> node scripts/install.js
Cached binary found at /root/.npm/node-sass/4.14.1/linux-x64-83_binding.node
> node-sass#4.14.1 postinstall /usr/local/lib/node_modules/node-sass
> node scripts/build.js
Binary found at /usr/local/lib/node_modules/node-sass/vendor/linux-x64-83/binding.node
Testing binary
/snap/node/2725/bin/node: symbol lookup error: /usr/local/lib/node_modules/node-sass/vendor/linux-x64-83/binding.node: undefined symbol: _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeEPKNS_9CFunctionE
npm WARN You are using a pre-release version of node and things may not work as expected
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! node-sass#4.14.1 postinstall: `node scripts/build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-sass#4.14.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
UPD:
I tried:
npm uninstall node-sass
After:
npm install node-sass
Did not help.
I tried:
npm install node-gyp global, save, savedev
ERROR in ./src/sсss/critical.scss (./node_modules/css-loader??ref--5-1!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/sсss/critical.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'
Require stack:
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/sass-loader/lib/loader.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/loadLoader.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/LoaderRunner.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/webpack/lib/NormalModule.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/webpack/lib/NormalModuleFactory.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/webpack/lib/Compiler.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/webpack/lib/webpack.js
- /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/webpack-dev-server/bin/webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
at Function.Module._load (internal/modules/cjs/loader.js:890:27)
at Module.require (internal/modules/cjs/loader.js:1080:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/gorevanova/Documents/WebStorm/webpack-static/node_modules/sass-loader/lib/loader.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Module.require (internal/modules/cjs/loader.js:1080:19)
at require (internal/modules/cjs/helpers.js:72:18)
at loadLoader (/home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/loadLoader.js:18:17)
at iteratePitchingLoaders (/home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
at iteratePitchingLoaders (/home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
at /home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/LoaderRunner.js:176:18
at loadLoader (/home/gorevanova/Documents/WebStorm/webpack-static/node_modules/loader-runner/lib/loadLoader.js:47:3)
But problem don't leave me.
Run this commands:
rm -rf ./node_modules ./package-lock.json, then
npm cache verify.
PS: I recommend to install nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Also I don’t know if you already have it, but make sure to also have build-essential install
$ sudo apt update && apt install build-essential
It is a set of c++ compilers and Bunch of useful 💩
something else that I have seen is the lack of python 2.x.x
$ sudo apt install python
Try this, it worked for me
npm i --unsafe-perm node-sass
Please check your node version before install it, node-sass has striction about node versions, shown as below:
refer to https://github.com/sass/node-sass
Cached binary found at /root/.npm/node-sass/4.14.1/linux-x64-83_binding.node
Binary found at /usr/local/lib/node_modules/node-sass/vendor/linux-x64-83/binding.node
Testing binary
I would say the issue could be the fact it's using a cached version from before you upgraded to Ubuntu 20, in which case, removing the cached binary would resolve this.
https://docs.npmjs.com/cli-commands/cache.html
This is just my assumption, what have you tried so far to resolve this issue?

Install expo cli errors at the end of install

So I'm following this tutorial to try and learn React Native: https://www.youtube.com/watch?v=qSRrxpdMpVc
And in the tutorial he shows to install expo cli using the line
'npm install expo-cli --global'
But when i run that line, i get a whole bunch of warnings saying for example:
npm WARN deprecated topo#3.0.3: This module has moved and is now available at #hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
In the tutorial he says to ignore this but at the end of the install i get this error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! envsub#3.1.0 postinstall: `test -d .git && cp gitHookPrePush.sh .git/hooks/pre-push || true`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the envsub#3.1.0 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! C:\Users\Alex\AppData\Roaming\npm-cache\_logs\2019-12-06T01_25_52_024Z-debug.log
and then when i try to run the line 'expo init first-app' to create a project i get this error:
Error: Cannot find module 'C:\Users\Alex\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
I also found a similar question with an answer of try running
npm cache clean --force
npm install -g expo-cli
So i tried that but it didnt work.
Does anyone know why i would be getting these errors? I tried reinstalling node but that doesnt seem to fix it. Thanks for the help in advance, keep in mind i am completely new to react native
Assuming that you have Node 10 LTS or greater installed, you can use npm to install the Expo CLI command line utility:
npm install -g expo-cli
expo init AwesomeProject
cd AwesomeProject
npm start # you can also use: expo start

Can't install any Node packages globally Ubuntu Digital Ocean

Tried everything. Tried all the steps below, didn't work so I nuked my droplet and rebuilt to start over and try again. I'm Using Ubuntu. First thing once I ssh into my droplet was install node and npm via:
https://nodejs.org/en/download/package-manager/
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then
npm -v
5.6.0
node -v
v8.11.3
Then I try to install a package globally. I tried electron and it failed so I began messing with the node modules folder as I was getting the permission error with the fix documented here:
https://askubuntu.com/questions/869168/node-modules-have-755-permissions-what-permissions-should-i-set-so-that-npm-don
No luck. So I tried the solution documented here:
NPM global install "cannot find module"
echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/.npm-global/lib/node_modules
So that didn't work either. This is the error now when I try and install any package globally:
npm install -g electron
I get:
Error: Cannot find module '/root/.npm-global/lib/node_modules/nightmare/node_modules/electron/install.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.8.7 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.8.7 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! /root/.npm/_logs/2018-08-03T03_26_03_827Z-debug.log
This error for any package I try to install. Not sure what else to try. Don't want to wipe out the droplet and start over...
I also had this issue but after adding sudo at start the issue went away.
like:
sudo npm -g install nodemon

Angular CLI v6.0.8 won't install

I've installed NodeJS via PPA on Ubuntu 18.04. However when running sudo npm install -g #angular/cli I get the error at the bottom of this post.
I am using node v10.6.0 and npm v6.1.0. I have tried these commands, with no luck:
A) sudo npm install -g #angular/cli#latest
B) npm install -g #angular/cli (no sudo)
C) sudo npm install -g angular-cli --unsafe-perm=true
One thing I noticed was that in case C it actually installs and works when running as sudo. But it doesn't work as a regular user ("bash: ng: command not found").
I have checked my PATH env variable and have confirmed that the result of npm bin -g (/usb/bin) is indeed in my PATH for all users.
Any help would be very much appreciated.
me#laptop:~$ sudo npm install -g #angular/cli
[sudo] password for me:
/usr/bin/ng -> /usr/lib/node_modules/#angular/cli/bin/ng
> #angular/cli#6.0.8 postinstall /usr/lib/node_modules/#angular/cli
> node ./bin/ng-update-message.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/#angular/cli/bin/ng-update-message.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#6.0.8 postinstall: `node ./bin/ng-update-message.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#6.0.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
FOUND IT! After much digging around I realized this was a permissions issue. A system-wide umask in the PAM module (Ubuntu) was set to create files and folders with more restrictive permissions than usual. This is what I did to get back to normal and get Angular CLI installed:
sudo vi /etc/pam.d/common-session
Then change this line: session optional pam_umask.so umask=077
To this: session optional pam_umask.so
Reboot, then: sudo npm install -g #angular/cli
Et Voilà!

Can't install electron because of permission error

I can't install electron via npm.
I try to execute with sudo but same error arose.
Also tried official method (https://docs.npmjs.com/getting-started/fixing-npm-permissions) but it didn't fix this problem.
os: Ubuntu 16.04
node version: 8.5.0
npm version: 5.4.2
I install electron 1.7.6 because latest version(1.7.8) has no Linux package.
npm install electron#1.7.6
electron#1.7.6 postinstall
/home/tombo/workspace/hatebu-viewer-client/node_modules/electron node
install.js
/home/tombo/workspace/hatebu-viewer-client/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, link
'/tmp/electron-tmp-download-9437-1506349033474/electron-v1.7.6-linux-x64.zip'
-> '/home/tombo/.electron/electron-v1.7.6-linux-x64.zip'
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! electron#1.7.6
postinstall: node install.js npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the electron#1.7.6 postinstall script. npm ERR!
This is probably not a problem with npm. There is likely additional logging output above.
```
Could anyone solve this problem?
thanks.
I think you not have to specify the version of electron. Instead you can just install it globally first by using this command:
$ sudo npm install -g electron --unsafe-perm=true
And then init your project with command:
$ npm init
$ npm install electron --save
The global installation is necessary to run your app with comman $ electron ..

Resources