What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that?

npm err! enoent this is related to npm not being able to find a file. react
npm err! errno -4058
npm err! code enoent
enoent: no such file or directory
node_modules staging
enoent error
node js
npm err! missing script: start

I'm trying to run npm install in the angular project folder I got from ASP.NET Boilerplate and I'm getting an error that is "related to npm not being able to find a file."

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install
npm WARN deprecated @types/moment@2.13.0: This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need @types/moment installed!
npm WARN codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
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 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'

npm ERR! path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.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\Jack\AppData\Roaming\npm-cache\_logs\2018-03-21T19_33_18_250Z-debug.log

I can clearly see that this is happening because my node_modules subfolder contains only a single folder structure with no files within it. That structure is:

node_modules\@angular-devkit\build-optimizer\node_modules

I have node 8.9.4, npm 5.6.0, and angular-cli 1.5.0 installed as well as typescript 2.0.0. The latter two packages have been installed globally.

Here is the package.json file contents:

{
    "name": "MyProject",
    "version": "0.0.0",
    "license": "MIT",
    "angular-cli": {},
    "scripts": {
        "ng": "ng",
        "start": "ng serve --host 0.0.0.0 --port 4200",
        "hmr": "ng serve --host 0.0.0.0 --port 4200 4201 --hmr -e=hmr",
        "test": "ng test",
        "pree2e": "webdriver-manager update --standalone false --gecko false",
        "e2e": "protractor"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^5.0.3",
        "@angular/common": "^5.0.3",
        "@angular/compiler": "^5.0.3",
        "@angular/core": "^5.0.3",
        "@angular/forms": "^5.0.3",
        "@angular/http": "^5.0.3",
        "@angular/platform-browser": "^5.0.3",
        "@angular/platform-browser-dynamic": "^5.0.3",
        "@angular/router": "^5.0.3",
        "@aspnet/signalr": "1.0.0-preview1-28189",
        "@types/bootstrap": "^3.3.33",
        "@types/jquery": "^3.2.12",
        "@types/jquery.blockui": "0.0.28",
        "@types/jquery.validation": "^1.16.3",
        "@types/lodash": "^4.14.62",
        "@types/moment": "^2.13.0",
        "@types/moment-timezone": "^0.2.34",
        "@types/signalr": "^2.2.33",
        "@types/toastr": "^2.1.33",
        "abp-ng2-module": "^1.3.0",
        "abp-web-resources": "^3.3.0",
        "animate.css": "^3.5.2",
        "block-ui": "^2.70.1",
        "bootstrap": "^3.3.7",
        "bootstrap-select": "^1.12.2",
        "chart.js": "^2.6.0",
        "core-js": "^2.4.1",
        "famfamfam-flags": "^1.0.0",
        "flot": "^0.8.0-alpha",
        "font-awesome": "^4.7.0",
        "jquery": "^3.1.1",
        "jquery-countto": "^1.2.0",
        "jquery-migrate": "^3.0.0",
        "jquery-slimscroll": "^1.3.8",
        "jquery-sparkline": "^2.4.0",
        "js-cookie": "^2.1.4",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "moment-timezone": "^0.5.13",
        "morris.js": "^0.5.0",
        "ngx-bootstrap": "^2.0.2",
        "ngx-pagination": "^3.0.3",
        "node-waves": "^0.7.5",
        "push.js": "1.0.4",
        "raphael": "^2.2.7",
        "rxjs": "^5.5.2",
        "signalr": "^2.2.1",
        "simple-line-icons": "^2.4.1",
        "spin.js": "^2.3.2",
        "sweetalert": "^2.0.8",
        "toastr": "^2.1.2",
        "ts-helpers": "^1.1.2",
        "web-animations-js": "^2.3.1",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@angular/cli": "^1.5.4",
        "@angular/compiler-cli": "^5.0.3",
        "@angularclass/hmr": "^2.1.3",
        "@types/jasmine": "^2.5.38",
        "@types/node": "^8.0.27",
        "codelyzer": "^3.1.2",
        "jasmine-core": "^2.5.2",
        "jasmine-spec-reporter": "^4.2.1",
        "karma": "^1.4.1",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-coverage-istanbul-reporter": "^1.3.0",
        "karma-jasmine": "^1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "nswag": "^11.12.7",
        "protractor": "^5.1.1",
        "ts-node": "^3.3.0",
        "tslint": "^5.7.0",
        "typescript": "2.4.2"
    }
}

When I run npm install, I can see the packages being downloaded into the .staging folder. At the point that the finalize command is run (see the log below), I can see that the package folders are being consolidated and copied somewhere, but that somewhere does not appear to be my node_modules subfolder other than the first set of subfolders as I have shown above. When the npm install completes, the .staging folder is deleted and all that I have left is that partial folder structure.

Admittedly I am new to Node development - I usually work on our ASP.NET Web API backends. I'm trying to get my development environment in sync with our front end developer's development environment. I have spent most of the day looking for a solution. I've tried uninstalling and reinstalling Node. I've tried different versions that match our front end developer's environment. I've tried using the latest versions of angular-cli and typescript and have fallen back to the versions I reference above in hopes that the "requires a peer" warnings would be resolved. I have searched for similar answers on this site. The closest one I have found remains unanswered.

Here is the end of the "complete log" referenced in the npm error output:

19577 silly saveTree | `-- tsutils@2.22.2
19577 silly saveTree +-- typescript@2.4.2
19577 silly saveTree +-- web-animations-js@2.3.1
19577 silly saveTree `-- zone.js@0.8.18
19578 warn codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19579 warn codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19580 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
19581 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'
19582 verbose optional SKIPPING OPTIONAL DEPENDENCY:
19582 verbose optional Please try running this command again as root/Administrator.
19583 verbose stack Error: ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19584 verbose cwd D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
19585 verbose Windows_NT 10.0.16299
19586 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
19587 verbose node v8.9.4
19588 verbose npm  v5.6.0
19589 error path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript
19590 error code ENOENT
19591 error errno -4058
19592 error syscall rename
19593 error enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19594 error enoent This is related to npm not being able to find a file.
19595 verbose exit [ -4058, true ]

Please advise.

Why do Node modules go into .staging folder?, How do you solve NPM error a complete log of this run can be found in? npm ERR! enoent. but it is working fine with npm@4 and npm@3. The package has not been updated in last 3 months so it should be caused by latest npm updates. The issue is reproducible with versions 5.0.0 and 5.0.1 too.

The following steps work for me:

  1. npm cache clean -f
  2. rm -rf node_modules
  3. npm i

npm ERR! A complete log of this run can be found in:, Package install failed, see above. Package install failed, see above. Possible temporary npm registry glitch, or corrupted local server cache. Run npm cache clean and/or try again later.; This can be caused by corporate proxies that give HTML responses to package.json requests.

Following what @viveknuna suggested, I upgraded to the latest version of node.js and npm using the downloaded installer. I also installed the latest version of yarn using a downloaded installer. Then, as you can see below, I upgraded angular-cli and typescript. Here's what that process looked like:

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g @angular/cli@latest
C:\Users\Jack\AppData\Roaming\npm\ng -> C:\Users\Jack\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/cli@1.7.3
added 75 packages, removed 166 packages, updated 61 packages and moved 24 packages in 29.084s

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g typescript
C:\Users\Jack\AppData\Roaming\npm\tsserver -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
C:\Users\Jack\AppData\Roaming\npm\tsc -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsc
+ typescript@2.7.2
updated 1 package in 2.427s

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>node -v
v8.10.0

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm -v
5.6.0

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn --version
1.5.1

Thereafter, I ran yarn and npm start in my angular folder and all appears to be well. Here's what that looked like:

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn
yarn install v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "win32" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@angular/cli > @schematics/angular@0.1.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".
warning "@angular/cli > @angular-devkit/schematics > @schematics/schematics@0.0.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".
warning " > codelyzer@3.2.2" has incorrect peer dependency "@angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0".
warning " > codelyzer@3.2.2" has incorrect peer dependency "@angular/core@^2.3.1 || >=4.0.0-beta <5.0.0".
[4/4] Building fresh packages...
Done in 232.79s.

D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm start

> MyProject@0.0.0 start D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
> ng serve --host 0.0.0.0 --port 4200

** NG Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
Date: 2018-03-22T13:17:28.935Z
Hash: 8f226b6fa069b7c201ea
Time: 22494ms
chunk {account.module} account.module.chunk.js () 129 kB  [rendered]
chunk {app.module} app.module.chunk.js () 497 kB  [rendered]
chunk {common} common.chunk.js (common) 1.46 MB  [rendered]
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 515 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.1 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 1.53 MB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 15.1 MB [initial] [rendered]

webpack: Compiled successfully.

npm install | how it works, What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that? - node.js. ENOENT during npm install #9633 itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent npm ERR! modules/protractor/node

Try the following steps: 1. Make sure you have the latest npm (npm install -g npm). 2. Add an exception to your antivirus to ignore the node_modules folder in your project. 3. $ rm -rf node_modules package-lock.json . 4. $ npm install

What could cause an error related to npm not being able - html, Describe the problem When attempting to run npm install in the Gutenberg directory, it fails with this error: `ENOENT: no such file or path to my local WP enironment]/wp-content/plugins/gutenberg/node_modules/ npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent. Ensure dependencies described correctly on package.json. Just type npm install and hit Enter. Check issue still exists. and If issue not resolved, continue these methods. type npm cache clean and hit Enter. type sudo npm install -g npm and hit Enter. Retry npm install and hit Enter.

I had the SAME issue today and it was driving me nuts!!! What I had done was upgrade to node 8.10 and upgrade my NPM to the latest I uninstalled angular CLI

npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli

I then verified my Cache from NPM if it wasn't up to date I cleaned it and ran the install again if npm version is < 5 then use npm cache clean --force

npm install -g @angular/cli@latest

and created a new project file and create a new angular project.

npm install fails with "ENOENT: no such file or directory" on , I get an error message that transitive dependency of the local dependency cannot be installed: ENOENT: no such file or directory, rename '/XYZ/npm-install-​local- npm ERR! enoent This is related to npm not being able to find a file. npm ERR! module without reinstalling that module would result in ENOENT errors. +1, had the same issue with the browserify package. The install showed no error, but it wasn't available in the npm ls -g or in the path. Doing the uninstall followed by another install fixed the issue.

Can't NPM Install: ENOENT: no such file or directory .staging/core-js , If the package has a package-lock or shrinkwrap file, the installation of dependencies will be Install the dependencies in the local node_modules folder. The package contents should reside in a subfolder inside the tarball (​usually it is called package/ ) This will fail if the version has not been published to the registry. Reinstall npm with a node version manager (recommended), or Manually change npm’s default directory; Reinstall npm with a node version manager. This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your

npm install for package with local dependency fails - bugs, For more details about the contents of each Node.js packages as well as any configuration tips, see the README file in the corresponding NPM package. It will remain fully supported but will not receive any further enhancements in future Note The functions included in the @sap/hdb-connection library have been  True and to make it work without globally installed, see #758 (comment).. That's a bug. npm adds node_modules/.bin to the PATH variable, and that's a feature. For some reason, it doesn't work with node-sass.

npm-install, For the details of how JavaScript IntelliSense works, including being based on Type declaration files are written in TypeScript so they can express the data For libraries that do not include typings, VS Code's Automatic Type Acquisition will If you have npm installed but still see a warning message, you can explicitly tell  I have been writing software since 1997 – web-based applications, desktop applications, server integrations, etc. My primary technologies are now .NET based although I have coded extensively in Java in the past.

Comments
  • Delete node_modules folder manually, then install the latest node.js, then run yarn from the Angular folder. It will solve your problem
  • Thank you @viveknuna. Once I upgraded the node.js, npm, angular-cli, and typescript and then installed yarn. I was able to run yarn successfully and then I was able to run npm startsuccessfully. What exactly did that do? That is – what should I learn from your suggestion?
  • @viveknuna, I was wondering though why the yarn command worked when the npm install command did not. Is there any insight you can share with me?
  • updated my answer, please check.
  • Although I used the procedure detailed in my answer below to actually fix my problem, @viveknuna provided the suggestions I needed to get the project working so I am accepting his answer "because it solved [my] problem [and] was most helpful in finding [my] solution".
  • @jlavallet that’s why I upvoted your answer buddy :) happy coding.
  • so the solution is to switch to yarn ;P
  • Good, it will help others :)
  • Unfortunately, this solution did not seem to fix my problem. I followed it to the point of creating a new project file and a new angular project. Maybe that was key but during the run of the npm uninstall --save-dev angular-cli command it appeared to be doing exactly the same things as before. This surprised me because I thought all I was doing was uninstalling angular-cli. As I said in my post though – I am new to Node.js development so I may have missed something fundamental. Also, as I said in my post – I tried to run npm install with the latest versions of everything without success.