Npm install no such file or directory windows

I've installed Node.js for Windows and I'm trying to install a package via npm. The command prompt is in the directory of the project (C:UsersusernameDesktopNodeTest), which contains a single

I’ve installed Node.js for Windows and I’m trying to install a package via npm. The command prompt is in the directory of the project (C:UsersusernameDesktopNodeTest), which contains a single helloworld.js file. Upon typing ‘npm install express’, I receive the following error:

ENOENT: no such file or direcotry, open 'C:Usersusernamepackage.json

I’m attempting this from a clean install and cmd is running as admin.

Any ideas?

Fabio Antunes's user avatar

asked Jul 1, 2016 at 10:52

Alex Godbehere's user avatar

Alex GodbehereAlex Godbehere

2,9916 gold badges34 silver badges55 bronze badges

1

I was facing the same issue. I firstly delete my node_modules and delete the cache by following command:

rm -rf node_modules && npm cache clean --force

then I delete the package-lock.json file from my project and then hit npm install in command prompt and it works.

sulaiman sudirman's user avatar

answered May 21, 2019 at 4:59

Vicky's user avatar

1

As already pointed out by Subburaj this is because you are missing a package.json.
Just run npm init to initialize that file for you; afterwards it should work.

answered Jul 1, 2016 at 11:00

DAXaholic's user avatar

DAXaholicDAXaholic

32.4k6 gold badges76 silver badges74 bronze badges

2

If you are working on a Windows machine using Vagrant/VM, there’s a chance that symlinks are the culprit for your problem. To determine if that is the case, simply copy your package.json and package-lock.json into a test directory that is not mounted/shared between OSs.

mkdir /tmp/symlinktest
cd {{your directory with your package*.json}}
cp package*.json /tmp/symlinktest
cd /tmp/symlinktest
npm install

If this results in a successful install, you’ll need to either exclude the node_modules directory from the mount (there’s various articles on doing this, however I can’t say I’ve had success) or run npm install outside the mounted volume.

answered Aug 25, 2020 at 20:20

Chris's user avatar

ChrisChris

1232 silver badges7 bronze badges

1

I deleted the package-lock.json and It worked for me.

answered Jun 15, 2021 at 11:12

Sonia's user avatar

SoniaSonia

1072 silver badges8 bronze badges

Basically I was Offline while I tried to install with npm, so go online and try
npm install again

answered Jun 3, 2019 at 10:23

Aravindh Sivalingam's user avatar

Check the project folder which you opened in microsoft visual code. Generally you are not in the right path so npm is not able to search the package.json … My project was in Document/hostel/hostel .. I opened Document/hostel … So npm tried to find the package.json in Documents folder .. When i entered one level inside to Document/hostel/hostel .. it was fixed.

answered Aug 17, 2019 at 7:00

Mushtaque Ahmed's user avatar

0

Note: I have managed to fight with this error, but if this can be of any help for debugging and making npm better, here’s my story… And plenty of logs, too.

I’m opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don’t understand.
  • Other (see below for feature requests):

What’s going wrong?

I was trying to install some dependencies. My package.json is well tested and, actually, identical one is running in a different directory just fine.

The error I’m getting:
ENOENT: no such file or directory, rename 'C:Userswojte.SURFACE-PRO-4Projektyreact-collision-detectortestnode_modulescreate-react-class' -> 'C:Userswojte.SURFACE-PRO-4Projektyreact-collision-detectortestnode_modules.create-react-class.DELETE'

Here’s my package.json file that fails to install
https://pastebin.com/3Fp6sKM7

And here’s the full log file:
https://1drv.ms/u/s!AuDm0u3ORBtMvLNa_YgXeY1csMYWsA

Notes:

  • the only interesting fact about my repo is that it refers to its parent folder (see line 17) to get one of the dependency (my repo is a test suite for another repo, placed in /test folder in it). However… ↙
  • two almost identical (npm-wise) repos I own install just fine
  • my parent repo has dependency react and react-dom both set to ">=15.5". The repo I’m having an issue with is set to next, which downloads as of now version 16.0.0-beta.5.
  • running npm install react@next produces the same error, heres the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNeY8b1ov67TcdiQA

I have tried the following:

  1. updating npm to the newest version — I was running 5.3.0 when I first saw the error.
  2. manually removing node_modules
  3. reinstalling npm and removing all its data in %appdata%.
    After reinstalling npm, I’ve installed parent repo again. Worked like a charm. Sadly, installing this repo failed again, here’s the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNdsT7TP91kO9no8Q
  4. removing package-lock.json files.
    After that, with clean state, I’ve run npm install on parent repo again. I got error: — Error: EPERM: operation not permitted, unlink.... I believe it’s connected to Error: EPERM: operation not permitted on npm 5.4 on windows #18380. Here’s the full log file: https://1drv.ms/u/s!AuDm0u3ORBtMvLNfelh0ppRVPWKxzA
  5. running npm in elevated command line
    That did not help and I still were getting suggestion to run command as root/Administrator.
  6. downgrading npm to 5.3.0
    That finally fixed it!

How can the CLI team reproduce the problem?

supporting information:

  • npm -v prints: 5.4.0
  • node -v prints: v8.3.0
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Windows 10, build 16281
  • Network issues:
    • Geographic location where npm was run: Kraków, Poland
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don’t use a proxy, but have limited or unreliable internet access.
    • I use super good optic fiber 500 Mbps connection in Poland’s best internet provider
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).


Photo from Unsplash

When running npm commands from the terminal, you may get an error with code ENOENT.

Here’s an example of the error message log when running the npm start command:

$ npm start

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /nsebhastian/Desktop/DEV/n-app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open 
'/nsebhastian/Desktop/DEV/n-app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

As you can see, there’s an error with code ENOENT that prevents npm start command from running successfully.

The code ENOENT means that npm fails to open a file or directory that’s required for executing the command.

The npm start command is used to run the start script in the package.json file.

When the package.json file isn’t found, then npm throws the ENOENT error.

To fix the error, you need to make sure that the file or directory needed for running the command is available.

In the case above, adding a package.json file to the project will solve the error.

If that doesn’t work, then you probably don’t have a start script in your package.json file.

Learn more here: How to fix npm start command not working

Also, make sure that you are running the command from the project directory, right where the package.json file is located.

npm commands don’t work when you run them from a parent or child directory.

npm install fails with code ENOENT

The ENOENT error may also appear when you run the npm install command.

Here’s an example of the error:

$ npm install

npm ERR! path /Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 
'/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates' -> '/Users/nsebhastian/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/.delegates.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

The error above happens because you have a dependency that doesn’t install correctly.

Here are the steps to resolve this issue:

  • Make sure you are using the latest npm version
  • Clean your npm cache
  • Delete node_modules folder and package-lock.json
  • Run npm install again

Run the following commands one by one from the terminal:

# 👇 update npm to the latest version
npm install -g npm@latest

# 👇 clean npm cache
npm cache clean --force

# 👇 delete node modules and package-lock.json 
npm rm -rf node_modules && rm package-lock.json

# 👇 retry installing dependencies
npm install

The npm install command should now run successfully.

And that’s how you solve the npm error code ENOENT: no such file or directory error.

I was working on a Node.js project and decided to run it on top of Windows Subsystem for Linux but it just wouldn’t work. The npm command would fail with a “no such file or directory error” like this:

$ npm install
/usr/bin/env: ‘bashr’: No such file or directory

Trying to Google this issue pointed me towards issues with Git, and initially I thought that it must’ve been because I had cloned the repository with Git for Windows. After all, the line endings in Windows and Linux differ from one another, Linux has n while Windows uses rn.

The real reason for this error was that I had installed Node.js on Windows, and it became automatically visible in WSL2! I had forgot to install Node on WSL2 it found the executable from the Windows side, as we can see from the which command:

$ which npm
/mnt/c/Program Files/nodejs//npm

Since you can execute Windows programs that are in the system path from WSL (try to run explorer.exe, for example) the npm executable from Program Files was also there, causing confursion. In contrast, if you don’t have any version of Node installed on your system the WSL prompt is going to suggest you to install one.

To fix this error you just have to install Node.js on WSL2. I recommend that you use nvm as it lets you manage the installations and easily switch between versions.

You can find the official stallation instructions here, but essentially you have to run this command:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

Restart the shell, start a new one, or run the commands that the installation scrips suggests, and you should be able to run the nvm command.

Finally, install the version you need:

The npm install and other commands should now work!

Introduction

The error exist as part of the title of this article is actually happens. It happen upon executing the command of ‘npm i nodemon’. The following is the command upon triggering the error message :

[root@10 crud]# npm i nodemon
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open '/media/sf_windows/nodejs/crud/package.json'
npm WARN crud No description
npm WARN crud No repository field.
npm WARN crud No README data
npm WARN crud No license field.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /media/sf_windows/nodejs/crud/node_modules/chalk/node_modules/supports-color/package.json.2679617430
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/media/sf_windows/nodejs/crud/node_modules/chalk/node_modules/supports-color/package.json.2679617430'
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!     /root/.npm/_logs/2021-03-04T10_40_27_067Z-debug.log
[root@10 crud]#

The main purpose is for installing a nodemon package. The nodemon package is very useful. As it available in this link  as one of the main source of the NodeJS information. It explains that nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.

Moreover, in that link, it explains that nodemon does not require any additional changes to your code or method of development. Furthermore, nodemon is a replacement wrapper for node. Additionally, in order to use nodemon, replace the word node on the command line when executing your script. But apparently, upon installing the nodemon package, the error above appear. Normally, the error above will not appear upon the standard installation of any nodejs packages.

As an additional information, vefore starting to resolve the problem, the following is the content of the root folder of the NodeJS application :

[root@10 crud]# ls -al
total 13
drwxrwx---. 1 root vboxsf 4096 Mar  4 05:31 .
drwxrwx---. 1 root vboxsf 4096 Mar  4 05:25 ..
-rwxrwx---. 1 root vboxsf  207 Feb 27 12:18 db_config.js
drwxrwx---. 1 root vboxsf    0 Feb 10 11:29 node_modules
-rwxrwx---. 1 root vboxsf 3136 Feb 10 11:29 package-lock.json
[root@10 crud]#

The node_modules folder is available after installing mysql module. But the installation of nodemon module fails.The following are the steps for solving the above error message :

1. First of all, try to initialize a NodeJS application. This will create a package.json file. The following is the execution of the command :

[root@10 crud]# npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install ` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (crud)
version: (1.0.0)
description:
entry point: (app.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /media/sf_windows/nodejs/crud/package.json:

{
  "name": "crud",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "dependencies": {
    "ansi-align": "^3.0.0",
    "braces": "^3.0.2",
    "anymatch": "^3.1.1",
    "clone-response": "^1.0.2",
    "chokidar": "^3.5.1",
    "decompress-response": "^3.3.0",
    "debug": "^3.2.7",
    "fill-range": "^7.0.1",
    "end-of-stream": "^1.4.4",
    "get-stream": "^4.1.0",
    "ignore-by-default": "^1.0.1",
    "ms": "^2.1.3",
    "minimist": "^1.2.5",
    "minimatch": "^3.0.4",
    "mimic-response": "^1.0.1",
    "mysql": "^2.18.1",
    "normalize-url": "^4.5.0",
    "normalize-path": "^3.0.0",
    "nopt": "^1.0.10",
    "once": "^1.4.0",
    "picomatch": "^2.2.2",
    "p-cancelable": "^1.1.0",
    "prepend-http": "^2.0.0",
    "pupa": "^2.1.1",
    "pump": "^3.0.0",
    "pstree.remy": "^1.1.8",
    "readdirp": "^3.5.0",
    "responselike": "^1.0.2",
    "registry-auth-token": "^4.2.1",
    "registry-url": "^5.1.0",
    "rc": "^1.2.8",
    "semver": "^5.7.1",
    "semver-diff": "^3.1.1",
    "signal-exit": "^3.0.3",
    "supports-color": "^5.5.0",
    "strip-json-comments": "^2.0.1",
    "string-width": "^4.2.2",
    "term-size": "^2.2.1",
    "strip-ansi": "^5.2.0",
    "to-regex-range": "^5.0.1",
    "type-fest": "^0.8.1",
    "to-readable-stream": "^1.0.0",
    "url-parse-lax": "^3.0.0",
    "touch": "^3.1.0",
    "typedarray-to-buffer": "^3.1.5",
    "undefsafe": "^2.0.3",
    "unique-string": "^2.0.0",
    "widest-line": "^3.1.0",
    "wrappy": "^1.0.2",
    "xdg-basedir": "^4.0.0",
    "write-file-atomic": "^3.0.3"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) y
[root@10 crud]#
[root@10 crud]# ls -al
total 57
drwxrwx---. 1 root vboxsf  4096 Mar  4 05:56 .
drwxrwx---. 1 root vboxsf  4096 Mar  4 05:25 ..
-rwxrwx---. 1 root vboxsf   188 Mar  4 05:56 app.js
-rwxrwx---. 1 root vboxsf   207 Feb 27 12:18 db_config.js
drwxrwx---. 1 root vboxsf 40960 Mar  4 05:41 node_modules
-rwxrwx---. 1 root vboxsf  1703 Mar  4 05:41 package.json
-rwxrwx---. 1 root vboxsf  3136 Feb 10 11:29 package-lock.json
[root@10 crud]#

Fortunately, the execution for creating the package.json file is a success as in the above output. The full reference exist in this link. So, in the above command output, the file with the name of ‘package.json’ exist. So, it suppose it will be able to solve the error appear in the above line as follows :

npm WARN enoent ENOENT: no such file or directory, open '/media/sf_windows/nodejs/crud/package.json'

2. Apparently, after executing the command again, the problem appear with another error message as follows :

[root@10 crud]# npm i nodemon
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/nodemon/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN crud@1.0.0 No description
npm WARN crud@1.0.0 No repository field.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /media/sf_windows/nodejs/crud/node_modules/cacheable-request/node_modules/pump/package.json.3495354389
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/media/sf_windows/nodejs/crud/node_modules/cacheable-request/node_modules/pump/package.json.3495354389'
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!     /root/.npm/_logs/2021-03-04T10_41_50_349Z-debug.log
[root@10 crud]#

3. Moreover, running the command ‘npm install’ to install the package dependencies as exist in the package.json file definition as follows is also failing  :

[root@10 crud]# npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN crud@1.0.0 No description
npm WARN crud@1.0.0 No repository field.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /media/sf_windows/nodejs/crud/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json.2484783542
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/media/sf_windows/nodejs/crud/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json.2484783542'
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!     /root/.npm/_logs/2021-03-04T10_58_26_376Z-debug.log
[root@10 crud]# 

Actually, the information about the ‘npm install’ command for further reference exist in this link.

4. Next, the attempt is to reinstall the npm package as follows :

[root@10 crud]# npm install npm -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@7.6.0
added 59 packages from 24 contributors, removed 241 packages and updated 194 packages in 19.783s
[root@10 crud]#

5. Last but not least, it is an attempt directly to install the nodemon package as follows :

[root@10 crud]# npm install nodemon --save
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../is-ci/bin.js
npm ERR! dest /media/sf_windows/nodejs/crud/node_modules/.bin/is-ci
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../is-ci/bin.js' -> '/media/sf_windows/nodejs/crud/node_modules/.bin/is-ci'
npm ERR!  [Error: EPERM: operation not permitted, symlink '../is-ci/bin.js' -> '/media/sf_windows/nodejs/crud/node_modules/.bin/is-ci'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../is-ci/bin.js',
npm ERR!   dest: '/media/sf_windows/nodejs/crud/node_modules/.bin/is-ci'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-03-04T15_30_35_961Z-debug.log
[root@10 crud]#

In the output of the above command execution, there is a problem with the permission in the operating system. Obviously, it is because the path is a path resulting of the folder mapping from the Windows operating system in the host machine.

So, the physical folder path of ‘/media/sf_windows’ actually exist in the host machine running with a Windows operating system.

Another Solution for Solving the Error Message

Since the problem is not in the npm tool either the NodeJS application itself, try to check the permission in the operating system. Below are attempts for solving it :

1. First of all, just try to set the SELinux mode into a permissive mode as follows :

[root@10 crud]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      32
[root@10 crud]# setenforce 0
[root@10 crud]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      32
[root@10 crud]#

2. After that, executing the ‘npm install nodemon –save’, it is still failing as in the previous output command. So, further attempt is to try to disable the SELinux by editing the file of ‘/etc/selinux/config’ and changing the following content :

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

3.  Next, after restarting the virtual server and then reattempt to execute the ‘npm install nodemon –save’, unfortunately it still fail as in the output execution before.

Final and Simple solution for Solving the Error Message

After attempting for several alternative solutions above, finally this is the last attempt. Actually, it is a simple solution. Just try to execute in another folder exist in the guest machine or directly inside the virtual server as follows for an example in the ‘/root/tmp’ folder :

[root@10 temp]# ls -al
total 4
drwxr-xr-x  2 root root  20 Mar  4 10:42 .
dr-xr-x---. 6 root root 249 Mar  4 09:07 ..
-rw-r--r--  1 root root  31 Mar  4 09:07 app.js
[root@10 temp]# npm install nodemon --save

added 119 packages, and audited 120 packages in 7s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[root@10 temp]# ls -al
total 92
drwxr-xr-x    3 root root    85 Mar  4 10:42 .
dr-xr-x---.   6 root root   249 Mar  4 09:07 ..
-rw-r--r--    1 root root    31 Mar  4 09:07 app.js
drwxr-xr-x  108 root root  4096 Mar  4 10:42 node_modules
-rw-r--r--    1 root root    52 Mar  4 10:42 package.json
-rw-r--r--    1 root root 78919 Mar  4 10:42 package-lock.json
[root@10 temp]#

Luckily, it works although there is only one file with the name of ‘apps.js’. Actually, the content of that file is also just one line of source ‘console.debug(“Test NodeJS”);’. So, the conclusion for solving the problem is simple.

Generally, executing npm tool in a mounted folder originally exist as a physical folder in the host machine running in Windows operating system eventually will fail. Unfortunately, no further time to seek for the reason.

Nodejs Error: ENOENT: no such file or directory

This tutorial guides you on how to fix Nodejs Error: ENOENT: no such file or directory while running your node project or any application which contains Nodejs component.

Nodejs Error: ENOENT: no such file or directory

When I tried to download guacamole-client whose frontend is developed using Nodejs, and I tried to setup installing guacamole natively on Windows machine.

After downloading the code, I was trying to build guacamole-client which includes Nodejs frontend component by running “mvn package” command as shown below. But it resulted with error “Error: ENOENT: no such file or directory, open ‘C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontenddistnpm-dependencies.txt’

> mvn package
---
---
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputdirectivesguacKey.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputdirectivesguacTextInput.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputstylestextInput.css" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptextInputtextInputModule.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchdirectivesguacTouchDrag.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchdirectivesguacTouchPinch.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcapptouchtouchModule.js" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcindex.html" (no NPM package)
[INFO] <i> [dependency-list-plugin] Skipping file dependency "srcrelocateParameters.js" (no NPM package)
[INFO] [webpack-cli] Error: ENOENT: no such file or directory, open 'C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontenddistnpm-dependencies.txt'
[INFO]     at Object.openSync (fs.js:476:3)
[INFO]     at Object.writeFileSync (fs.js:1467:35)
----
[INFO]     at AsyncSeriesHook.lazyCompileHook (C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontendnode_modulestapablelibHook.js:154:20)
[INFO]     at C:UsersDocumentsWorkguacamole-client-masterguacamolesrcmainfrontendnode_moduleswebpacklibCompilation.js:1414:32 {
[INFO]   errno: -4058,
[INFO]   syscall: 'open',
[INFO]   code: 'ENOENT',
[INFO]   path: 'C:\Users\Documents\Work\guacamole-client-master\guacamole\src\main\frontend\dist\npm-dependencies.txt'
[INFO] }
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! @ build: `webpack --progress`
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the @ build script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     C:UsersAppDataRoamingnpm-cache_logs21-07-28T14_42_52_884Z-debug.log

The above command “mvn package” is supposed to invoke maven to automatically build and package all the components, producing a single .war file. And while building frontend Nodejs component, it was looking for a file called “npm-depedencies.txt” but that file is missing.

Solution

As you can see from the above error, that it is expecting file called “npm-dependencies.txt” to be there in specific path. But it does not exist.

code: 'ENOENT',

path: 'C:\Users\Documents\Work\guacamole-client-master\guacamole\src\main\frontend\dist\npm-dependencies.txt'

ENOENT means Error NO ENTry (or Error NO ENTity) or simply you can say that there is NO such directory ENTry.

Therefore, you either need to create the expected file in the specific path i.e., under dist directory or else reconfigure your application so that it will point to the correct directory path for the required file.

After fixing, try building your application again. The Nodejs Error: ENOENT: no such file or directory should have gone away now.

Hope it helped 🙂

Also see:

  • Call ngOnInit() again from another function – Angular 9 ?
  • ngOnChanges get new value and previous value – Angular
  • Global Angular CLI version is greater than your local version
  • Upgrade Angular CLI to the latest version Angular 9 or 10 ?
  • How to use new static option in ViewChild Angular 9 ?
  • Project contents into angular components using ng-content
  • Call ngOnInit() again from another function – Angular 9 ?
  • ngAfterContentInit with Example – Angular
  • make npm install command to work behind proxy ?
  • Node Sass could not find a binding for your current environment
  • ngOnDestroy Example Angular
  • Angular Component : In which lifecycle hook you can check value of DOM element ?
  • @ContentChild TypeError: Cannot read property ‘nativeElement’ of undefined
  • Access ng-content with @ContentChild – Angular Component
  • How to select an element in a component template – Angular ?
  • Difference between @ViewChild and @ContentChild – Angular Example
  • Expected 0 type arguments, but got 1 : Angular
  • Angular – Access template reference variables from component class ?
  • Pass variable from parent to custom child component – Angular 9
  • Uninstall Nodejs completely from Mac OSX ?
  • EventEmitter parameter value undefined for listener
  • Typescript Error: Property does not exist on value of type
  • Remove http and https proxy settings of npm and git ?
  • How to change node version using nvm ?

References:

  • github nvm
  • nodejs docs

Понравилась статья? Поделить с друзьями:
  • Npm install g jshint windows как установить
  • Npfs sys синий экран windows 10
  • Npf sys windows 10 как удалить
  • Nperf speed test скачать для windows 10 бесплатно
  • Npcap скачать для windows 7 x64