ENONENT after updating (main.js / main.ts)

Hello.

At first this morning I built my app with ionic cordova build android.
It worked fine. But when I did ionic serve for tests, it opened a web page with a ENONENT error.

I didn’t pay much attention to it, because I saw there were updates for ionic / angular / … I haven’t made. I made them, and now I can’t even build anymore. I’ve tried to remove node_modules and reinstall it, but nothing seem to work;
I have the ENONENT error stating that there’s no src\app\main.js which is obviously right since that folder contains a main.ts and not main.js

Any way to solve this issue ?

post the full error message

Here it is :

D:\DocsFlo\fpAuth>ionic cordova build android
Running app-scripts build: --build --iscordovaserve --externalIpRequired --nobrowser

[10:11:24]  build dev started ...
[10:11:24]  clean started ...
[10:11:24]  clean finished in less than 1 ms
[10:11:24]  copy started ...
[10:11:24]  transpile started ...
[10:11:30]  transpile finished in 5.47 s
[10:11:30]  preprocess started ...
[10:11:30]  deeplinks started ...
[10:11:30]  deeplinks finished in 62 ms
[10:11:30]  preprocess finished in 78 ms
[10:11:30]  webpack started ...
[10:11:30]  copy finished in 5.86 s
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your
       plugins may be out of date.
Error: D:/Userfiles/fgoumot-labesse/Documents/fpAuth/src/app/main.ts
Module build failed: Error: ENOENT: no such file or directory, open 'D:\Userfiles\fgoumot-labesse\Do
cuments\fpAuth\src\app\main.js'
    at Error (native)

D:\DocsFlo\fpAuth>

You have written there that your cordova plugin is out of date, reinstall it or update.

Not sure if that’s what I was supposed to do (still a newbie with npm/ionic/etc) but that’s what I have :

D:\DocsFlo\fpAuth>npm i @ionic/cli-plugin-cordova
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Do
csFlo\fpAuth\node_modules\.staging\fsevents-859284ad\node_modules\ajv' -> 'D:\DocsFlo\fpAuth\node_mo
dules\.staging\ajv-f31549e5'

+ @ionic/cli-plugin-cordova@1.5.0
added 114 packages and updated 1 package in 244s

D:\DocsFlo\fpAuth>ionic cordova build android
Running app-scripts build: --build --iscordovaserve --externalIpRequired --nobrowser

[10:33:20]  build dev started ...
[10:33:20]  clean started ...
[10:33:20]  clean finished in less than 1 ms
[10:33:20]  copy started ...
[10:33:20]  transpile started ...
[10:33:25]  transpile finished in 4.57 s
[10:33:25]  preprocess started ...
[10:33:25]  deeplinks started ...
[10:33:25]  deeplinks finished in 63 ms
[10:33:25]  preprocess finished in 63 ms
[10:33:25]  webpack started ...
[10:33:26]  copy finished in 5.17 s
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your
       plugins may be out of date.
Error: D:/Userfiles/fgoumot-labesse/Documents/fpAuth/src/app/main.ts
Module build failed: Error: ENOENT: no such file or directory, open 'D:\Userfiles\fgoumot-labesse\Do
cuments\fpAuth\src\app\main.js'
    at Error (native)

Post your ionic info output so we have an idea what we are dealing with here.

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.3.0

System:

    Node       : v6.10.3
    OS         : Windows 7
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 5.3.0

Note that I tried to downgrade from 3.6.0 to 3.4.0 because I thought I had this version before the bug, but eh it didn’t change anything

Please update your CLI and app-scripts to the most current versions. Read the changelogs for breaking changes. Then try again.

I’ve updated to latest the following: @ionic/cli-plugin-cordova, @ionic/app-scripts.
When I wanted to update @ionic/cli-utils though, I’ve gotten an error:

D:\DocsFlo\fpAuth>npm i @ionic/cli-utils@latest
npm ERR! path D:\DocsFlo\fpAuth\node_modules\fsevents\node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'D:\DocsFlo\fpAuth\node_modules\fsevents\nod
e_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\DocsFlo\fpAuth\node_modules\fsevents\
node_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\DocsFlo\\fpAuth\\node_module
s\\fsevents\\node_modules\\getpass\\node_modules\'\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\DocsFlo\\fpAuth\\node_modules\\fsevents\\node_modules\\getpass\\node_modules'
}
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\fgoumot-labesse\AppData\Roaming\npm-cache\_logs\2017-08-01T12_45_26_394Z-debug
.log

Maybe is there a way to clean everything and reinstall “from scratch” to be sure it will work ?
(by the way I’ve tried to run it normally and as admin, nothing worked)

Delete the node_modules folder, package-lock.json and run npm install.
Maybe also first try everything with a new, empty project via ionic start blank blank and see that everything works there.

I tried to make a new blank app.
When done, I used ionic serve, which opened the browser but with the same error…

Runtime Error
Module build failed: Error: ENOENT: no such file or directory, open 'D:\Userfiles\fgoumot-labesse\Documents\tst\blank\src\app\main.js' at Error (native)
Stack
Error: Module build failed: Error: ENOENT: no such file or directory, open 'D:\Userfiles\fgoumot-labesse\Documents\tst\blank\src\app\main.js'
    at Error (native)
    at Object.<anonymous> (http://localhost:8100/build/main.js:5:7)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at webpackJsonpCallback (http://localhost:8100/build/vendor.js:26:23)
    at http://localhost:8100/build/main.js:1:1
Ionic Framework: 3.6.0
Ionic App Scripts: 2.1.3
Angular Core: 4.1.3
Angular Compiler CLI: 4.1.3
Node: 6.10.3
OS Platform: Windows 7
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Edit: I have the issue with ENONENT as stated previously when I run my app with build android, but when I use same command as for the blank app (ionic serve) I get another error which is

Runtime Error
webpackJsonp is not defined
Stack
ReferenceError: webpackJsonp is not defined
    at http://localhost:8100/build/main.js:1:1

Edit 2: when adding

<script src="build/vendor.js"></script> 

in the index.html, I get back to the original ENONENT error for my app.

If you have errors in a new project something is very broken. I would advise you to uninstall global Ionic and reinstall it, then again try to create a new project.

If this also doesn’t work, delete your local node installation and install nvm-windows. Use it to reinstall node and then install Ionic and try again with a new project.

Solved… Finally!
What I did:

Removed node_modules folder. Then follow this procedure:

Open the Node.js command prompt as administrator.
Run: npm cache clean
Run: npm uninstall -g ionic
Run: npm uninstall -g cordova
Run: npm install -g ionic
Run: npm install -g cordova

After that, make sure VS code is closed otherwise npm install will fail.

Link: https://github.com/npm/npm/issues/14003

Thanks for the help & time you spent helping.

The VS Code problem has been fixed in the July release of VS Code and should not be a problem any more.

Well I’ve been speaking too quickly.
The error is back, but this time I know when it started.

First, ionic cordova build android worked like I said.
Then I wanted to try ionic serve.
Here is how it went:

D:\DocsFlo\fpAuth>ionic serve
[WARN] No local CLI detected.
       Starting with CLI 3.6, the CLI must be installed locally to use local CLI plugins.

? Install now? Yes
> npm install --save-dev --save-exact ionic@latest
x Running command - failed!
[ERROR] Error occurred while loading plugins. CLI functionality may be limited.

And then, I ran ionic serve again and got ENOENT back. Retried build for android:

D:\DocsFlo\fpAuth>ionic cordova build android
Running app-scripts build: --build --iscordovaserve --externalIpRequired --nobrowser

[16:09:15]  build dev started ...
[16:09:15]  clean started ...
[16:09:15]  clean finished in 7 ms
[16:09:15]  copy started ...
[16:09:15]  transpile started ...
[16:09:21]  transpile finished in 6.49 s
[16:09:21]  preprocess started ...
[16:09:21]  deeplinks started ...
[16:09:21]  deeplinks finished in 140 ms
[16:09:21]  preprocess finished in 145 ms
[16:09:21]  webpack started ...
[16:09:22]  copy finished in 7.54 s
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: D:/Userfiles/fgoumot-labesse/Documents/fpAuth/src/app/main.ts
Module build failed: Error: ENOENT: no such file or directory, open 'D:\Userfiles\fgoumot-labesse\Do
cuments\fpAuth\src\app\main.js'
    at Error (native)

EDIT: I confirm.
I just ran npm install again, and I got this:

D:\DocsFlo\fpAuth>ionic cordova build android
[WARN] No local CLI detected.
       Starting with CLI 3.6, the CLI must be installed locally to use local CLI plugins.

? Install now? No
[WARN] Not loading local CLI plugins in global mode. CLI functionality may be limited.
> cordova build android
√ Running command - done!

I skipped the rest, but it built successfully. SO it seems the error comes when I say yes.

Can you run this manually and tell us the output?

It gives

D:\DocsFlo\fpAuth>npm install --save-dev --save-exact ionic@latest
npm ERR! path D:\DocsFlo\fpAuth\node_modules\fsevents\node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'D:\DocsFlo\fpAuth\node_modules\fsevents\nod
e_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\DocsFlo\fpAuth\node_modules\fsevents\
node_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\DocsFlo\\fpAuth\\node_module
s\\fsevents\\node_modules\\getpass\\node_modules\'\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\DocsFlo\\fpAuth\\node_modules\\fsevents\\node_modules\\getpass\\node_modules'
}
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\fgoumot-labesse\AppData\Roaming\npm-cache\_logs\2017-08-01T14_25_17_684Z-debug
.log

Btw the build for android is successful but app is lighter (5mb instead of 8), and after showing the loading screen I have infinite white screen. Not sure if that’s because of a change or because it has “the bug”, since I haven’t touched it for a while.

(And yes, now it doesn’t build anymore so that’s the problem)

When running in node.js prompt as admin:

D:\DocsFlo\fpAuth>npm install --save-dev --save-exact ionic@latest
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/common@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/compiler@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/compiler-cli@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/core@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/forms@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/http@4.1.3 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/platform-browser@4.1.3 but none was install
ed.
npm WARN ionic-angular@3.6.0 requires a peer of @angular/platform-browser-dynamic@4.1.3 but none was
 installed.
npm WARN ionic-angular@3.6.0 requires a peer of rxjs@5.4.0 but none was installed.
npm WARN ionic-angular@3.6.0 requires a peer of zone.js@0.8.12 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":
"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ ionic@3.6.0
added 118 packages in 38.823s

No error here, but still have the same problem of ENOENT when building no matter the case.

Yeah, before we lose too much time here: Delete your node installation (and the global Ionic with it). Install nvm-windows and install node again. Then install Ionic globally again. Then try again.

This will take care of any possible permission problems your node installation seems to be having here.

I’ve uninstalled Ionic, Cordova, Node, and installed back from the beginning.
I created a new project once again, same error.

So I’ve taken a look at the folder I was working in. Seems like it was a shortcut, but since I was previously using it without any problem, I didn’t think it could be the problem.
I just tried to make a new project near the root of my D:, ensuring no shortcut, and this time it seemed to work.

Lastly, I copied my already existing -and buggy- app folder near the root. It does work now