Unable to create new ionic project

hi, I am unable to create a new project of any kind(blank, tabs etc). When running “ionic start TestApp blank” I get these 2 errors:

[ERROR] Error with .\TestApp\node_modules\ionic-angular\package.json file: FILE_NOT_FOUND
[ERROR] Error with .\TestApp\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND

this is the log in the cmd prompt:

C:\MobileProjects>ionic start TestApp blank
√ Creating directory .\TestApp - done!
√ Downloading and extracting blank starter - done!

? Would you like to integrate your new app with Cordova to target native iOS and Android? Yes
√ Personalizing ionic.config.json and package.json - done!

ionic integrations enable cordova --quiet
√ Downloading integration cordova - done!
√ Copying integrations files to project - done!
[OK] Added cordova integration!
[ERROR] Error with .\TestApp\node_modules\ionic-angular\package.json file: FILE_NOT_FOUND
[ERROR] Error with .\TestApp\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND

Installing dependencies may take several minutes.

  • IONIC DEVAPP *

Speed up development with the Ionic DevApp, our fast, on-device testing mobile app

  • Test on iOS and Android without Native SDKs
    
  • LiveReload for instant style and JS updates
    

️–> Install DevApp: Ionic DevApp - Appflow

npm i

  • Running command

this part takes like 15 mins, the this shows up:

[ERROR] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename
    'C:\MobileProjects\TestApp\node_modules\.staging\fsevents-0deb5a78\node_modules\asn1' ->
    'C:\MobileProjects\TestApp\node_modules\.staging\asn1-b9d76088'

    npm ERR! path C:\MobileProjects\TestApp\node_modules\@angular-devkit\build-optimizer\node_modules\source-map
    npm ERR! code ENOENT
    npm ERR! errno -4058
    npm ERR! syscall rename
    npm ERR! enoent ENOENT: no such file or directory, rename
    'C:\MobileProjects\TestApp\node_modules\@angular-devkit\build-optimizer\node_modules\source-map' ->
    'C:\MobileProjects\TestApp\node_modules\@angular-devkit\build-optimizer\node_modules\.source-map.DELETE'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\fabian\AppData\Roaming\npm-cache\_logs\2018-03-16T20_24_24_144Z-debug.log

C:\MobileProjects>

I have uninstalled node, cordova, ionic more than 3 times, cleaned the npm cache , reboot the computer etc and so far nothing has worked.I tried also with the latest stable node version(8.10)

These are my settings:

Windows 10

C:\MobileProjects>node -v
v9.8.0
C:\MobileProjects>ionic -v
3.20.0
C:\MobileProjects>cordova -v
8.0.0
C:\MobileProjects>npm -v
5.6.0

is anybody else having the same issue ?

Do these files really not exist?

Your problem is probably with npm, something to do with permissions and files. This happens quite often and is almost impossible to successfully debug (at least here in the forum).

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.

thank you,
1- the files are not there, I guess that the ionic start command among other things should trigger that part, because I am just creating a new app

2- just did that: uninstalled cordova, ioic, node, restart pc. then downloaded nvm-windows, install node 8.10.0, then installed cordova and ionic, and I am in the same place,

I even cloned a project made from me on a Mac, and when doing npm install it also fails.

However I can still work on exiting projects on my machine, make changes, deploy to device etc

Please run npm install manually in one of those projects and show the output.
What is you ionic info output in your project?

1- npm install takes forever and I terminate the command after 15 mins or so of nothing happening

C:\MobileProjects\ionicdialer4>npm install
Terminate batch job (Y/N)?

2- this is ionic info on such a project:

C:\MobileProjects\ionicdialer4>ionic info

cli packages: (C:\Users\fabian\AppData\Roaming\nvm\v8.10.0\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.6
Cordova Platforms  : android 7.0.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.0.1
Node              : v8.10.0
npm               : 5.6.0
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\Users\fabian\AppData\Local\Android\sdk\

Misc:

backend : pro

C:\MobileProjects\ionicdialer4>

3- However, I can deploy it to my phone: ionic cordova ruin android, these are the last lines

BUILD SUCCESSFUL in 15s
47 actionable tasks: 1 executed, 46 up-to-date
Built the following apk(s):
C:\MobileProjects\ionicdialer4\platforms\android\app\build\outputs\apk\debug\app-debug.apk
ANDROID_HOME=C:\Users\fabian\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_131
No target specified, deploying to device ‘0123456789ABCDEF’.

none
Skipping build…
Built the following apk(s):
C:\MobileProjects\ionicdialer4\platforms\android\app\build\outputs\apk\debug\app-debug.apk

Using apk: C:\MobileProjects\ionicdialer4\platforms\android\app\build\outputs\apk\debug\app-debug.apk

Package name: com.aurisvoipdemo.ild
LAUNCH SUCCESS

[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?

This is the issue then. Do you get anything interesting with --verbose added at the end of the command?

This is running the command prompt as Administrator, notice how it says “Please try running this command again as root/Administrator.” at the end

also the folder “.staging” does not exist inside “node_modules”

it looks like it is trying to do something with that file but since it is not there it fails, but since the operation is not permitted it is treating is as lack of privileges ??

this is the log of the whole thing:

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd .

C:\WINDOWS\system32>cd ..

C:\Windows>cd ..

C:\>cd MobileProjects\BLETest

C:\MobileProjects\BLETest>npm install --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   '--verbose' ]
npm info using npm@5.6.0
npm info using node@v8.10.0
npm verb npm-session e940572566c1d42a
npm info lifecycle BLETest@0.0.1~preinstall: BLETest@0.0.1
npm verb correctMkdir C:\Users\fabian\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using C:\Users\fabian\AppData\Roaming\npm-cache\_locks\staging-dfb142a84407e5c6.lock for C:\MobileProjects\BLETest\node_modules\.staging
npm verb unlock done using C:\Users\fabian\AppData\Roaming\npm-cache\_locks\staging-dfb142a84407e5c6.lock for C:\MobileProjects\BLETest\node_modules\.staging
npm info linkStuff BLETest@0.0.1
npm verb linkBins BLETest@0.0.1
npm verb linkMans BLETest@0.0.1
npm info lifecycle BLETest@0.0.1~install: BLETest@0.0.1
npm info lifecycle BLETest@0.0.1~postinstall: BLETest@0.0.1
npm info lifecycle BLETest@0.0.1~prepublish: BLETest@0.0.1
npm info lifecycle BLETest@0.0.1~prepare: BLETest@0.0.1
npm verb saving []
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\MobileProjects\BLETest\node_modules\.staging\fsevents-02ca263d\node_modules\aproba' -> 'C:\MobileProjects\BLETest\node_modules\.staging\aproba-b7bb43ba'
npm verb optional SKIPPING OPTIONAL DEPENDENCY:
npm verb optional Please try running this command again as root/Administrator.

up to date in 70.371s
npm verb exit [ 0, true ]
npm info ok

C:\MobileProjects\BLETest>

Never run anything as admin - this is almost always a red herring.

Can you run the initial ionic start command with --verbose please and post the complete output?

never run as admin: noted

Between these 2 lines there was a span of 10 minutes
npm i
× Running command - failed!

This is is the whole thing as my user: (by the way I appreciate your help a lot on this matter)

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\fabian>ionic -v
3.20.0

C:\Users\fabian>cordova -v
8.0.0

C:\Users\fabian>node -v
v8.10.0

C:\Users\fabian>npm -v
5.6.0

C:\Users\fabian>nvm list

  * 8.10.0 (Currently using 64-bit executable)
C:\Users\fabian>ionic start myTestMarch20 blank --verbose
[DEBUG] Reason for not using local CLI: BASE_DIRECTORY_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'C:\\Users\\fabian', local: false, binPath:
        'C:\\Users\\fabian\\AppData\\Roaming\\nvm\\v8.10.0\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\fabian\\AppData\\Roaming\\nvm\\v8.10.0\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 17112)
√ Creating directory .\myTestMarch20 - done!
√ Downloading and extracting blank starter - done!

? Would you like to integrate your new app with Cordova to target native iOS and Android? Yes
√ Personalizing ionic.config.json and package.json - done!
> ionic integrations enable cordova --quiet
√ Downloading integration cordova - done!
[DEBUG] Integration files downloaded to C:\Users\fabian\AppData\Local\Temp\ionic-integration-cordova (files: config.xml,
        resources)
[DEBUG] Blacklist:
√ Copying integrations files to project - done!
[OK] Added cordova integration!

Installing dependencies may take several minutes.

  *   IONIC  DEVAPP  *

 Speed up development with the Ionic DevApp, our fast, on-device testing mobile app

  -     Test on iOS and Android without Native SDKs
  -     LiveReload for instant style and JS updates

 ️-->    Install DevApp: https://bit.ly/ionic-dev-app    <--

> npm i
× Running command - failed!
[ERROR] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):

        npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename
        'C:\Users\fabian\myTestMarch20\node_modules\.staging\fsevents-cc71627f\node_modules\ansi-regex' ->
        'C:\Users\fabian\myTestMarch20\node_modules\.staging\ansi-regex-a894069b'

        npm ERR! path C:\Users\fabian\myTestMarch20\node_modules\@angular-devkit\build-optimizer\node_modules\source-map
        npm ERR! code ENOENT
        npm ERR! errno -4058
        npm ERR! syscall rename
        npm ERR! enoent ENOENT: no such file or directory, rename
        'C:\Users\fabian\myTestMarch20\node_modules\@angular-devkit\build-optimizer\node_modules\source-map' ->
        'C:\Users\fabian\myTestMarch20\node_modules\@angular-devkit\build-optimizer\node_modules\.source-map.DELETE'
        npm ERR! enoent This is related to npm not being able to find a file.
        npm ERR! enoent

        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\fabian\AppData\Roaming\npm-cache\_logs\2018-03-20T20_12_49_062Z-debug.log



C:\Users\fabian>

Really strange, somehow npm can’t create and move files there.

Can you try in another location, maybe even a USB stick or something that is not on your primary hard disk?

Thank you Sujan12, I tried it on a USB stick and it was taking too long but while I was thinking on what else could it be I realized that our IT Dept had installed MalwareBytes on our PCs a few days ago. I never got a warning or anything from malwarebytes while I was working on this but I disabled it and it works now. Your last comment was what made me think on the antivirus or the malwarebytes app. My coworker had the antivirus running and I was able to create a project on his pc but he did not have the malwarebytes running that is why it was working on his pc.
Nevertheless, thank you very much, I appreciate it a lot.
I created 2 projects and they were fine. This is the out put of one of them. Case closed!

C:\Users\fabian>ionic start TestFBMarch21-1 blank --verbose
[DEBUG] Reason for not using local CLI: BASE_DIRECTORY_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'C:\\Users\\fabian', local: false, binPath:
        'C:\\Users\\fabian\\AppData\\Roaming\\nvm\\v8.10.0\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\fabian\\AppData\\Roaming\\nvm\\v8.10.0\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 121356)
√ Creating directory .\TestFBMarch21-1 - done!
√ Downloading and extracting blank starter - done!

? Would you like to integrate your new app with Cordova to target native iOS and Android? Yes
√ Personalizing ionic.config.json and package.json - done!
> ionic integrations enable cordova --quiet
√ Downloading integration cordova - done!
[DEBUG] Integration files downloaded to C:\Users\fabian\AppData\Local\Temp\ionic-integration-cordova (files: config.xml,
        resources)
[DEBUG] Blacklist:
√ Copying integrations files to project - done!
[OK] Added cordova integration!

Installing dependencies may take several minutes.

  *   IONIC  DEVAPP  *

 Speed up development with the Ionic DevApp, our fast, on-device testing mobile app

  -     Test on iOS and Android without Native SDKs
  -     LiveReload for instant style and JS updates

 ️-->    Install DevApp: https://bit.ly/ionic-dev-app    <--

> npm i
√ Running command - done!
> git init

  *   IONIC  PRO  *

 Supercharge your Ionic development with the Ionic Pro SDK

  -     Track runtime errors in real-time, back to your original TypeScript
  -     Push remote updates and skip the app store queue

Learn more about Ionic Pro: https://ionicframework.com/products

? Install the free Ionic Pro SDK and connect your app? No

-----------------------------------

> git add -A
> git commit -m "Initial commit" --no-gpg-sign

Next Steps:
* Go to your newly created project: cd .\TestFBMarch21-1
* Get Ionic DevApp for easy device testing: https://bit.ly/ionic-dev-app


C:\Users\fabian>cd TestFBMarch21-1

C:\Users\fabian\TestFBMarch21-1>ionic serve
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser -
Ctrl+C to cancel
[11:23:59]  watch started ...
[11:23:59]  build dev started ...
[11:23:59]  clean started ...
[11:23:59]  clean finished in 2 ms
[11:23:59]  copy started ...
[11:23:59]  deeplinks started ...
[11:23:59]  deeplinks finished in 12 ms
[11:23:59]  transpile started ...
[11:24:02]  transpile finished in 3.23 s
[11:24:02]  preprocess started ...
[11:24:02]  preprocess finished in 2 ms
[11:24:02]  webpack started ...
[11:24:02]  copy finished in 3.37 s
[11:24:06]  webpack finished in 4.60 s
[11:24:06]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[11:24:07]  sass finished in 969 ms
[11:24:07]  postprocess started ...
[11:24:07]  postprocess finished in 7 ms
[11:24:07]  lint started ...
[11:24:07]  build dev finished in 8.98 s
[11:24:08]  watch ready in 9.04 s
[11:24:08]  dev server running: http://localhost:8100/

[OK] Development server running!
     Local: http://localhost:8100
     External: http://10.0.75.1:8100, http://172.31.196.224:8100, http://192.168.56.1:8100, http://192.168.152.1:8100,
     http://192.168.44.1:8100
     DevApp: TestFBMarch21-1@8100 on fborot-pc

[11:24:10]  lint finished in 2.37 s
^CTerminate batch job (Y/N)?
^C
C:\Users\fabian\TestFBMarch21-1>

Awesome!

I hate software that messes with normal usage.