Can't Run a 2015 Ionic Project after Windows OS re-install

I can’t get to run my ionic project after windows OS re-installation. I kept getting various errors which I solved one by one. Still stuck at Can’t load internal/fs. This is n old but very important project. I was forced to re-install my Windows OS as I got a blue screen. I then installed ionic and nodejs on the new machine and tried ionic serve, now it’s dead. Please help me out from this nightmare! All my code will be of no use… :frowning:

I know that most of the errors may be because of version mismatch with npm,node,ionic etc… And I did a big mistake of not noting down the version numbers of the previous environment.

What is your ionic info output?
What is your project’s package.json content?

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Gulp CLI : not installed globally

local packages:

Ionic Framework : ionic1 1.1.1

System:

Node : v8.2.1
npm  : 5.3.0
OS   : Windows 10
{
  "name": "***",
  "version": "1.1.1",
  "description": "******",
  "dependencies": {
    "gulp-sass": "^2.0.4",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0"
  },
  "devDependencies": {
    "@ionic/cli-plugin-gulp": "1.0.2",
    "@ionic/cli-plugin-ionic1": "2.0.1",
    "async": "^1.5.0",
    "bower": "^1.7.1",
    "clean-css": "^3.4.8",
    "cordova-uglify": "^0.2.3",
    "gulp": "^3.9.1",
    "gulp-angular-templatecache": "^1.8.0",
    "gulp-concat": "^2.6.0",
    "gulp-minify-css": "^0.3.13",
    "gulp-ng-annotate": "^1.1.0",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.1.1",
    "gulp-useref": "file:gulp-useref",
    "gulp-util": "^3.0.7",
    "jshint": "^2.9.1-rc1",
    "mv": "^2.1.1",
    "ng-annotate": "^1.0.2",
    "shelljs": "^0.5.3",
    "uglify-js": "^2.6.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "android"
  ]
}

This all looks okay.

What errors are you getting when exactly?

When I try to run ionic serve --lab Right now I’m stuck at this:

[ERROR] Gulpfile (or dependent module) not found: .\gulpfile.js

    For custom Gulpfile locations, you can run ionic config set gulp.file <path>. Otherwise, the default Ionic
    Gulpfile can be downloaded from https://github.com/ionic-team/ionic-app-base/blob/master/gulpfile.js

    Or, if you don't use gulp, you can disable it by running ionic config set gulp.enabled false.
    Full error:

    Error: Cannot find module 'internal/fs'
        at Function.Module._resolveFilename (module.js:485:15)
        at Function.Module._load (module.js:437:25)
        at Module.require (module.js:513:17)
        at require (internal/module.js:11:18)
        at evalmachine.<anonymous>:40:20
        at Object.<anonymous>
    (F:\programming\Nodejs\dso_minify_vs\node_modules\bower\node_modules\graceful-fs\fs.js:11:1)
        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)

I tried “npm cache verify” and “npm cache clean” with no luck

This is my gulpfile.js

var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');

var paths = {
  sass: ['./scss/**/*.scss']
};

gulp.task('default', ['sass']);

gulp.task('sass', function(done) {
  gulp.src('./scss/ionic.app.scss')
    .pipe(sass())
    .on('error', sass.logError)
    .pipe(gulp.dest('./www/css/'))
    .pipe(minifyCss({
      keepSpecialComments: 0
    }))
    .pipe(rename({ extname: '.min.css' }))
    .pipe(gulp.dest('./www/css/'))
    .on('end', done);
});

gulp.task('watch', function() {
  gulp.watch(paths.sass, ['sass']);
});

gulp.task('install', ['git-check'], function() {
  return bower.commands.install()
    .on('log', function(data) {
      gutil.log('bower', gutil.colors.cyan(data.id), data.message);
    });
});

gulp.task('git-check', function(done) {
  if (!sh.which('git')) {
    console.log(
      '  ' + gutil.colors.red('Git is not installed.'),
      '\n  Git, the version control system, is required to download Ionic.',
      '\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
    );
    process.exit(1);
  }
  done();
});
var templateCache = require('gulp-angular-templatecache');
  var paths = {
    templatecache: ['./www/templates/**/*.html']
  };
  gulp.task('templatecache', function (done) {
    gulp.src('./www/templates/**/*.html')
      .pipe(templateCache({standalone:true}))
      .pipe(gulp.dest('./www/js'))
      .on('end', done);
  });
  gulp.task('default', ['sass', 'templatecache']);
  gulp.task('watch', function() {
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.templatecache, ['templatecache']);
  });
   var ngAnnotate = require('gulp-ng-annotate');
  var paths = {
    ng_annotate: ['./www/js/*.js']
  };
  gulp.task('ng_annotate', function (done) {
    gulp.src('./www/js/*.js')
      .pipe(ngAnnotate({single_quotes: true}))
      .pipe(gulp.dest('./www/dist/dist_js/app'))
      .on('end', done);
  });
  gulp.task('default', ['sass', 'templatecache', 'ng_annotate']);
  gulp.task('watch', function() {
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.templatecache, ['templatecache']);
    gulp.watch(paths.ng_annotate, ['ng_annotate']);
  });
   var useref = require('gulp-useref');
  var paths = {
    useref: ['./www/*.html']
  };
  gulp.task('useref', function (done) {
    var assets = useref.assets();
    gulp.src('./www/*.html')
      .pipe(assets)
      .pipe(assets.restore())
      .pipe(useref())
      .pipe(gulp.dest('./www/dist'))
      .on('end', done);
  });
  gulp.task('default', ['sass', 'templatecache', 'ng_annotate', 'useref']);
  gulp.task('watch', function() {
    gulp.watch(paths.sass, ['sass']);
    gulp.watch(paths.templatecache, ['templatecache']);
    gulp.watch(paths.ng_annotate, ['ng_annotate']);
    gulp.watch(paths.useref, ['useref']);
  });

I don’t have much experience with Ionic v1.

But: I would try the default gulpfile linked in the error message.

If this doesn’t work, create a new Ionic v1 project (ionic start myApp --type=ionic1) and compare to your package.json file. One solution: Uninstall your node, install nvm (or nvm-windows if you are on Windows), install a new node (which includes npm) with this, then install ionic and cordova again and try your command again.

Should I also install ionic and cordova along with node?

How do I do this? Please help me with steps

Uninstall node will also kill all the packages installed with npm. But as i wrote, this option should only be used if all the other stuff didn’t work.

Open the URL, replace your local gulpfile with what you see there, try again.

Now I got this:

Error: Cannot find module ‘gulp-sass’

I think this will keep giving me errors untill I install all dependencies. I tried npm update and npm install gulp-sass --save-dev as I see here

and now I get this error:

Error: Cannot find module ‘json-stringify-safe’
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (F:\programming\Nodejs\dso_minify_vs\node_modules\request\lib\helpers.js:3:25)
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)
at Function.Module._load (module.js:458:3)
npm WARN Error: EPERM: operation not permitted, scandir ‘F:\programming\Nodejs\dso_minify_vs\node_modules\cliui\node_modules’
npm WARN { Error: EPERM: operation not permitted, scandir ‘F:\programming\Nodejs\dso_minify_vs\node_modules\cliui\node_modules’
npm WARN stack: ‘Error: EPERM: operation not permitted, scandir 'F:\programming\Nodejs\dso_minify_vs\node_modules\cliui\node_modules'’,
npm WARN errno: -4048,
npm WARN code: ‘EPERM’,
npm WARN syscall: ‘scandir’,
npm WARN path: ‘F:\programming\Nodejs\dso_minify_vs\node_modules\cliui\node_modules’ }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 install: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.13.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Did you run npm install for your project?
Did you compare your package.json with that of a new project?

Yes I must’ve earlier… I compared the package.json of a new project the packages are different than what I have in the this(old) Project.

Also in the old project I had ionic.project file. With new Ionic that has changed to ionic.config.json. Then I had to create an ionic.config.json for this one to get started. I didn’t know that in a couple of years there would be such drastic changes :slight_smile:
Or may be my understanding about ionic is wrong.

What exactly is different? Only versions or is real stuff missing? What version of ionic is the new project vs your old one?

Well, a couple years more and Ionic didn’t even exist. Add a few more years and it’s the same for iOS and Android…

Not only versions but package names are also different.

Current Ionic versions

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2
Ionic Framework : ionic1 1.1.1

As I said earlier I didn’t make a note of the earlier versions, does this mean I can’t run my project unless I know what version it used before?

No, I asked you to compare the newly created project (that works) with the project you already have (that is not working right now). Show us what is different.

There is no reason why an old Ionic v1 project should not work with the current CLI.