Error with "ionic start" - new project


#1

I get this error:

 Error: Cannot find module '/Users/SubEffect/node_modules/ionic'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /usr/local/lib/node_modules/ionic/bin/ionic:18:13 code: 'MODULE_NOT_FOUND' }

after installing ionic, and using “ionic start myApp”

What am I doing wrong?


#2

How did you install ionic?
Had you installed it before?

What is your ionic info output?
Linux/Mac: What does which ionic return?
Windows: What does where ionic return?


#3

Yes, I’ve used ionic a lot. I used v1 and v2 and this has never happened before. As I said in the OP, I installed ionic (I sudo installed it in fact).

I’m on Mac. Ionic info gives me exactly the same error as the one I posted in the OP.

And the answer to "which ionic"is: /usr/local/bin/ionic


#4

Where are you running the commands, which folder are you in in your command line?
Output of npm list -g --depth=0 please.

Did you have Ionic installed on this machine before?
Using sudo is always a red flag to me and should not really be necessary…

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. The problem should be gone.


#5

Ionic seems to run fine with serve in a my other project.

This is from the depth test:

/usr/local/lib
├── bower@1.5.3
├── cordova@7.1.0
├── firebase-tools@3.1.0
├── gulp@3.9.1
├── ionic@3.13.1
├── ios-deploy@1.8.2
├── ios-sim@3.1.1
├── n@2.1.7
├── node-gyp@3.5.0
├── npm@3.10.10
├── plugman@0.22.16
└── typescript@1.8.10

npm ERR! extraneous: JSONStream@1.3.0 /usr/local/lib/node_modules/npm/node_modules/JSONStream
npm ERR! extraneous: lazy-property@1.0.0 /usr/local/lib/node_modules/npm/node_modules/lazy-property
npm ERR! extraneous: mississippi@1.3.0 /usr/local/lib/node_modules/npm/node_modules/mississippi
npm ERR! extraneous: sorted-union-stream@2.1.3 /usr/local/lib/node_modules/npm/node_modules/sorted-union-stream
npm ERR! extraneous: uuid@3.0.1 /usr/local/lib/node_modules/npm/node_modules/uuid
npm ERR! extraneous: osenv@0.1.4 /usr/local/lib/node_modules/npm/node_modules/nopt/node_modules/osenv
npm ERR! extraneous: supports-color@0.2.0 /usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color
npm ERR! extraneous: punycode@1.4.1 /usr/local/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie/node_modules/punycode
npm ERR! missing: normalize-package-data@*, required by npm@1.3.4
npm ERR! missing: inherits@, required by fstream-npm@0.1.4

I’ve just reinstalled node.


#6

Oh, so it works in another project but not this one?
Can you post the ionic info from there please?


#7

From the other folder?

WARN] Error with ./www/lib/ionic/version.json file: FILE_NOT_FOUND, trying 
       ./bower.json.

cli packages: (/Users/SubjectiveEffect/DAS2/node_modules)

    @ionic/cli-utils  : 1.13.0
    ionic (Ionic CLI) : 3.13.0

local packages:

    Ionic Framework : ionic1 1.1.0

System:

    Node : v8.7.0
    npm  : 5.4.2 
    OS   : macOS Sierra

Misc:

    backend : legacy

I just uninstalled and reinstalled node. npm list -g --depth=0 now gives this:

/usr/local/lib
├── cordova@7.1.0
├── ionic@3.13.1
└── npm@5.4.2

Ionic start still doesn’t work.


#8

I’ve just tested a different Ionic 2 project and it works fine.

I do get this error with “ionic info” though:

Error with ./www/lib/ionic/version.json file: FILE_NOT_FOUND, trying 
       ./bower.json.

Ionic serve & ionic serve --lab have not working in 3.19.0
#9

This error should only appear on ionic v1 problems that are strange…

Can you run npm list --depth=0 in a project where you get the original error?


#10

There is no project - that’s the problem. This is the root folder. I usually create my projects here with “ionic start”.

This is what I get from “npm list --depth=0” from that folder:

zchat@1.0.0 /Users/SubEffect
├── bower@1.7.9
├── gulp@3.9.1
├── gulp-concat@2.6.0
├── gulp-minify-css@0.3.13
├── gulp-rename@1.2.2
├── gulp-sass@1.3.3
├── gulp-util@2.2.20
├── ionic@2.2.1 extraneous
├── shelljs@0.3.0
└── uuid@3.1.0
npm ERR! extraneous: ionic@2.2.1 /Users/SubEffect/node_modules/ionic

That’s it.

Any help?


#11

Ah, that’s strange.
Is there an ionic file in that directory as well?

Run which ionic please in your user directory.


#12

“which ionic” give me

/usr/local/bin/ionic

All a bit odd.


#13

No, that is actually correct.

Hm, is there a package.json in you user directory? Can you post its content?
Try renaming the node_modules folder in there to something else and try to create a project again.


#14

This is package.json:

{
  "name": "zchat",
  "version": "1.0.0",
  "description": "zChat: An Ionic project",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0",
    "gulp-sass": "^1.3.3",
    "uuid": "^3.1.0"
  },
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-util": "^2.2.14",
    "shelljs": "^0.3.0"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "ios"
  ]
}

Renaming node_modules worked.

Why have I got ionic 2 stuff hanging around?


#15

So your problem is all fixed?

You probably ran “npm install ionic” instead of “npm install -g ionic” in your user directory some time ago. This installed it into node_modules there which was no problem when you were inside a project, which has its own Ionic CLI installation, but only when you want to access Ionic CLI in the user directory. The global installation gets triggered and looks for a local installation (which it normally doesn’t find for ionic start) and uses that one. As your in the user directory was broken, you got an error.

Update: Created an issue that could prevent this in the future: https://github.com/ionic-team/ionic-cli/issues/2810


#16

Yes, it’s fixed. Thank you.