Error when installing @ionic/app-scripts or build

Hi guys
Somehow I destroyed something and I can’t build our Ioniv v3 app anymore. Probably it has to do with a version which is not supported. I know that @ionic/app-scripts is not installed anymore but when I try to do it I get an error too. I need to downgrade something? Cordova? Node?

Ionic:

   ionic (Ionic CLI)  : 4.2.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : not installed

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 6.4.0, browser 5.0.3, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.1, (and 11 other plugins)

System:

   NodeJS : v10.1.0 (/usr/local/bin/node)
   npm    : 6.4.1
   OS     : macOS
   Xcode  : Xcode 9.3 Build version 9E145

HI,

What is your error log when you try to install @ionic/app-scripts ?

Root14

Thank you very much for helping. I get this:

> ionic-app-scripts build --prod --target cordova --platform android

[INFO] Looks like @ionic/app-scripts isn't installed in this project.

       This package is required for this command to work properly.

? Install @ionic/app-scripts? Yes
> npm i -D -E @ionic/app-scripts
npm WARN checkPermissions Missing write access to /Users/thatsme/ionic-project/node_modules
npm WARN checkPermissions Missing write access to /Users/thatsme/ionic-project/node_modules/@ionic
npm ERR! path /Users/thatsme/ionic-project/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/thatsme/ionic-project/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/Users/thatsme/ionic-project/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/Users/thatsme/ionic-project/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/Users/thatsme/ionic-project/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/thatsme/.npm/_logs/2018-10-10T09_11_10_727Z-debug.log
[ERROR] An error occurred while running subprocess npm.

        npm i -D -E @ionic/app-scripts exited with exit code 243.

        Re-running this command with the --verbose flag may provide more information.

node/npm didn’t have the write access to your node_modules.

The fast way is to use :

sudo npm i -D -E @ionic/app-scripts

But the good way is to understand why npm can’t access to the node_modules folder.

You can look to this sources to find a solution :

https://docs.npmjs.com/getting-started/fixing-npm-permissions

The first solution with sudo didn’t help:

MBP-2:wrio-ionic thatsme$ sudo npm i -D -E @ionic/app-scripts
Password:

> node-sass@4.9.0 install /Users/thatsme/ionic-project/node_modules/node-sass
> node scripts/install.js

Unable to save binary /Users/thatsme/ionic-project/node_modules/node-sass/vendor/darwin-x64-64 : { Error: EACCES: permission denied, mkdir '/Users/thatsme/ionic-project/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:854:3)
    at sync (/Users/thatsme/ionic-project/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/Users/thatsme/ionic-project/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/Users/thatsme/ionic-project/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/Users/thatsme/ionic-project/node_modules/node-sass/scripts/install.js:157:1)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
  errno: -13,
  syscall: 'mkdir',
  code: 'EACCES',
  path: '/Users/thatsme/ionic-project/node_modules/node-sass/vendor' }

Can you try to remove your node_modules folder and run npm install ?

I could fix it by changing the permissions. Some folders only had system access and not user access. It seems to work for now but I’m sure I have to install everything properly in the future as it’s propably a huge mess…

nvm is much easier to use and allows installing multiple ecosystems at once.