ENOENT: no such file or directory when running npm install command - node.js

When I run npm install, I getting the following error,
npm WARN tar ENOENT: no such file or directory, open 'D:\Live Project\insyte-mobile\insyte-mobile\node_modules.staging\core-js-c9f4d03d\library\fn\symbol\unscopables.js'
Here is a screen shoot of the error
:
Here is my package.json
{
"name": "tonight-mobile",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "~27.0.0",
"react-test-renderer": "16.3.1"
},
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"eject": "expo eject",
"initial-android": "npm install && npm run android",
"initial-ios": "npm install && npm run ios",
"android": "expo start --android",
"ios": "expo start --ios",
"test": "jest",
"postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^32.0.0",
"expo-image-picker": "^5.0.2",
"firebase": "^5.7.1",
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.2.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-firebase": "^5.1.1",
"react-native-image-crop-picker": "^0.21.3",
"react-native-image-picker-form": "^0.2.5",
"react-native-maps": "^0.21.0",
"react-native-responsive-image": "^2.3.1",
"react-native-swiper": "^1.5.14",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.13.0",
"react-navigation-tabs": "^1.0.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-persist": "^5.10.0",
"redux-persist-filesystem-storage": "^1.3.2",
"redux-thunk": "^2.3.0",
"tcomb-form-native": "^0.6.20"
}
}
above is the package.json file.
I have also used another code of this project, but this time I'm getting following error :

First delete the package-lock.json and then try npm install

Delete node_modules folder and package-lock.json, then run npm install

All you need to do is
Open a terminal in your pc's root and run this command:
killall node
Before restart the new metro bundler please reinstall the dependencies on yarn or npm :
npm i OR yarn
Also the article: ENOENT: no such file

Follow this step:
Delete node_modules folder and package-lock.json file
Run this command:
npm cache clean -force
Then run this command:
npm install (if the issue is not yet fixed try the following 4th step.)
Run this command npm install -g npm,then npm install
Finally run this command: npm start

Please check your current working directory. if you have created project using
npx react-native init demo
then navigate inside project from terminal using
cd demo
npm install
will install all npm modules and you can also check installed packages in the directory: demo/node_modules
also if project is expo base then
run expo eject to eject from expo

Check the node version, if the application was build using an older node version then you can downgrade your local environment node version using NVM (node version manager).

My simple solution for this error:
"npm WARN tar ENOENT:no such file or directory
Not only for ENOENT if all files in npm modules shows this kinds of error.
Go to your command prompt
Check for npm version(npm -v)
If its giving a version then type command npm init and click on enter for whatever it asks
After completing all the steps and then again try to create one angular project. It will be created without any errors in node modules.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path E:\Projects\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'E:\Projects\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
Solution ==> Check the root directory you might be outside the root directory or in wrong folder path has been opened

I suspect you do not have git installed on your computer. This is particularly true if you are getting this error at the bottom of your log:
npm ERR! syscall spawn git
If so, then you need to install git from here: https://git-scm.com/downloads.
I had the same problem as you, and once I installed git, the problem went away.

Do you have a package.json file in the folder ?*
To run npm install you need to have a package.json file.

Related

Can't install node-sass#6 for node v16

This is my package.json after uninstalling sass node-sass and sass-loader because I changed my node version from 14 to 16,
{
"name": "our-awesome-project",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"static": "NUXTJS_DEPLOY_TARGET=static NUXTJS_SSR=true nuxt generate",
"build-and-start": "NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt build && NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt start"
},
"husky": {
"hooks": {
"pre-commit": "cross-env PRE_COMMIT=true lint-staged -r"
}
},
"dependencies": {
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"nuxt-i18n": "^6.28.1",
"nuxt-purgecss": "^1.0.0",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"webpack": "^4.46"
},
"devDependencies": {
"#nuxtjs/eslint-config": "^8.0.0",
"#nuxtjs/google-fonts": "^1.3.0",
"#nuxtjs/storybook": "^4.2.0",
"#nuxtjs/style-resources": "^1.2.1",
"#vue/cli-plugin-babel": "^4.5.15",
"babel-eslint": "^10.1.0",
"eslint": "^8.7.0",
"husky": "^7.0.4",
"nuxt-svg-loader": "^1.2.0",
"postcss": "^8.4.5"
}
}
According to this I should install node-sass version 6.0
But I'm trying:
npm install --save-dev sass#1.49.0 node-sass#6.0.1 sass-loader#10.2.1
Also, read here to add --unsafe-perm so I tried:
npm install --save-dev --unsafe-perm sass#1.49.0 node-sass#6.0.1 sass-loader#10.2.1
But it keeps failing, being the first error always this one:
npm ERR! code 1
npm ERR! path /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/user/.nvm/versions/node/v16.13.1/bin/node /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
I tried removing node_modules package-lock.json and the same result
Of course, this is driving me nuts.. please tell me that anyone has an idea to try out
I think you are using ARM64 which is not supported by node-sass.
You should replace node-sass with sass(Dart Sass) as LibSass is deprecated
Just replace node-sass in your package.json file with sass. Both packages expose the same JavaScript API.
npm uninstall node-sass
npm install --save-dev sass
We have a Nuxt 2.15.8 app running on Node 16, in which a couple of months ago we switched from node-sass to sass, as the former is deprecated.
I recall at the time it took some figuring out, but in the end we just needed to install some postcss parsers to get the Nuxt app fully working with sass & sass-loader.
Taking as the baseline the package.json in your post, try:
npm install --save-dev \
sass#1.49.4 \
sass-loader#10.2.1 \
postcss-html#1.3.0 \
postcss-scss#4.0.3
The error message hints to node-gyp as the culprit. To work on a MacOS, node-gyp requires the XCode Command Line Tools to be installed (see here). So basically, in case you haven't done that yet, run
xcode-select --install
Or try any of the other methods described here. Then retry to install node-sass.
in fact , I think you have pasted the wrong error infomation.
there are two ways may help you
npm i --force this command will ignored the error in the package.json
use the pnpm , you can install it by
npm i -g pnpm
# then
pnpm i

How do I solve npm install issue after deleting node_modules

I am trying to clean out my react-native project's package to do a clean npm install on a MacOS based system (my windows system for Android development has no issues in cleaning up package versions).
I started seeing errors in the npm instals complaining version differences betwces are not compatible and list differences between versions of each package in "rook project" and node_modules/ directory.
I do the usual fix by removing package-lock.json, delete the node_modules directory and re-run npm install. from my project folder. It immediately made the same error complaints. The problem is this, there is no node_modules in my project folder as I deleted it. And it did not create a new node_modules directory.
Given this issue, how do I debug this and fix it? Questions I'd like to find out:
how do I tell npm to tell me what it thinks root project value is (full path)?
How to tell npm to tell me where the full path to the node_modules directory it seems to see?
Finally, how do I force npm to do the right thing and focus my my project's collaterals and not look outside the project folder as it appears to be doing?
Some of my thoughts. I don't understand why it is making a package cersion comparison between root project and node_modules?
Seems that nodde and npm are doing different things in MacOS environment than in my windows system environment -- I don't understand this.
Anyone here can help me understand what is going on and how to solve it?
The Error output here:
thomas#Presonus americanaradio % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AmericanaRadio#0.0.2
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.13.1" from the root project
npm ERR! peer react#"^16.8" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.2" from react-native#0.66.4
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.66.3" from the root project
npm ERR! peer react-native#">=0.59" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency
resolution.
npm ERR!
npm ERR! See /Users/thomas/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/thomas/.npm/_logs/2021-12-10T15_47_02_669Z-debug.log
thomas#Presonus americanaradio %
The package.json content here:
{END)
"name": "AmericanaRadio",
"version": "0.0.2",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/async-storage": "^1.12.1",
"#react-native-community/checkbox": "^0.5.2",
"#react-native-community/masked-view": "^0.1.10",
"#react-native-community/slider": "^3.0.3",
"node-fetch": "^2.6.1",
"react": "^16.13.1",
"react-native": "^0.66.3",
"react-native-background-timer": "^2.4.1",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-reanimated": "^2.2.4",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.15.2",
"react-native-simple-survey": "^3.1.2",
"react-native-swift": "^1.2.1",
"react-native-vector-icons": "^8.0.0",
"react-native-version-check": "^3.4.2",
"react-native-version-info": "^1.1.0",
"react-native-webview": "^11.3.1",
"react-navigation": "^4.4.3",
"react-navigation-drawer": "^2.6.0",
"react-navigation-stack": "^2.10.2",
"react-usestateref": "^1.0.8",
"socket.io-client": "^4.4.0"
},
"devDependencies": {
"#babel/core": "^7.12.10",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.18.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
~
(END)
As noted in my description, the node_modules directory was deleted and running npm install failed and did not create a nodes_modules directory. So the error messages are confusing as I have no packages in my project directory (americanaradio).
Thank you for taking a look at this and hopefully a solution can come out of ths.
First check what library is giving you an error and try to reinstall or update that version . Try deleting node modules also . Then do npm install.

Node.js app runs locally but fails on docker (sh: 1: rimraf: not found)

I am able to build the docker image but can't get the container to run. Here is the package.json:
{
"name": "linked-versions-viewer",
"version": "1.0.0",
"description": "...",
"main": "./dist/bundle.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"build_only": "rollup -c",
"build": "cross-env NODE_ENV=production npm run clean && npm run build_only",
"serve": "parcel src/index.html --port 12345",
"start": "npm run clean && npm run serve"
},
"repository": {
"type": "git",
"url": "..."
},
"author": "...",
"license": "...",
"dependencies": {
"antd": "^4.12.3",
"base-widget": "...",
"react": "^17.0.2",
"react-dom": "^17.0.1"
},
"devDependencies": {
"#types/node": "^14.14.28",
"#types/react": "^17.0.2",
"#types/react-dom": "^17.0.1",
"cross-env": "^7.0.3",
"parcel-bundler": "^1.12.4",
"rev-hash": "^3.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.39.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-uglify": "^6.0.4",
"typescript": "^4.1.5"
}
}
Here is the dockerfile:
FROM node:14.17.0 as base
ENV NODE_ENV=production
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
FROM base as production
ENV NODE_PATH=./build
CMD ["npm", "start"]
I created the image by running docker build -t testapp . and tried running the container with docker run -p 8080:8080 -d testapp but it keeps immediately exiting with code 1. This is the error log for the image:
> linked-versions-viewer#1.0.0 start /app
> npm run clean && npm run serve
> linked-versions-viewer#1.0.0 clean /app
> rimraf dist
sh: 1: rimraf: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! linked-versions-viewer#1.0.0 clean: `rimraf dist`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the linked-versions-viewer#1.0.0 clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-06-09T20_40_17_204Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! linked-versions-viewer#1.0.0 start: `npm run clean && npm run serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the linked-versions-viewer#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I tried just removing the rimraf dependency altogether but then got a similar error for the parcel dependency, so maybe the packages aren't being installed properly? The app is also written in typescript if that's helpful.
Not sure what to try next. Thank you for any suggestions.
Form npm install docs,
With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies
Since you have ENV NODE_ENV=production in your base image, neither rimraf nor parcel-bundler is installed inside your container.
Your npm start command is running npm run clean && npm run serve. npm run clean uses rimraf module and npm run serve uses parcel-bundler module. This is the reason why you're seeing both the errors.
You can try one of the following solutions,
Remove ENV NODE_ENV=production from your Dockerfile (This is the quickest solution but should not be used in production)
You can install rimraf and parcel-bundler globally inside the container using:
RUN npm install --global rimraf && npm install --global parcel-bundler
However, I still don't think this is a good production-ready setup.
You can properly build your app using npm run build inside your container and serve it. However, I am not familiar with React enough to help you set up this on Docker.

Google Cloud: Create A Simple Application With the API samples npm install failed

Following the instruction from here, https://cloud.google.com/bigquery/create-simple-app-api
cd to the samples folder
https://github.com/googleapis/nodejs-bigquery/tree/master/samples
The package.json is
https://github.com/googleapis/nodejs-bigquery/blob/master/samples/package.json
{
"name": "nodejs-docs-samples-bigquery",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"repository": "googleapis/nodejs-bigquery",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "repo-tools test run --cmd npm -- run cover",
"ava": "ava -T 3m --verbose test/*.test.js system-test/*.test.js",
"cover": "nyc --reporter=lcov --cache ava -T 3m --verbose test/*.test.js system-test/*.test.js && nyc report"
},
"dependencies": {
"#google-cloud/bigquery": "1.2.0",
"#google-cloud/storage": "1.5.1",
"yargs": "10.0.3"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "2.1.3",
"ava": "0.24.0",
"nyc": "11.3.0",
"proxyquire": "1.8.0",
"sinon": "4.1.3",
"uuid": "3.1.0"
}
}
I run
npm install
I get errors
Home-iMac:samples user1$ npm install
npm WARN #google-cloud/bigquery#1.2.0 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
npm ERR! path /Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is' -> '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#sindresorhus/is-79439449'
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! /Users/user1/.npm/_logs/2018-04-27T19_38_14_391Z-debug.log
To fix the error, a hack solution is instead of using the package.json to install, I have to run this manually first
npm install --save #google-cloud/bigquery
Then I can run
npm install
again. This time, it will finish without problem.
But I would like to be able to just simply using package.json, using npm install only to install the packages.
I changed the package.json
From
"#google-cloud/bigquery": "1.2.0",
to
"#google-cloud/bigquery": "^1.2.0",
It still does not work.
Thanks!
#Tim - Thanks for the request to update, #google/bigquery 1.3.0 is being used for the example. The download link to the GitHub site was updated, but the sample code on the page itself is not updated.

react-scripts: not found on create-react-app project on ubuntu?

I am working on reactjs using this one
https://github.com/facebookincubator/create-react-app
But when i deploy it to digitalocean on top of ubuntu 16
I can not run npm run build and got this as an error.
deploy#xxxx:/www/tmdb_admin$ sudo npm run build
[sudo] password for deploy:
> tmdb_admin#0.1.0 build /www/tmdb_admin
> react-scripts build
sh: 1: react-scripts: not found
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v7.3.0
npm ERR! npm v4.0.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! tmdb_admin#0.1.0 build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the tmdb_admin#0.1.0 build script 'react-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tmdb_admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tmdb_admin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tmdb_admin
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /www/tmdb_admin/npm-debug.log
So this is my package.json file.
{
"name": "tmdb_admin",
"version": "0.1.0",
"private": true,
"devDependencies": {
"autoprefixer-stylus": "0.10.0",
"concurrently": "3.0.0",
"react-scripts": "0.6.1",
"stylus": "0.54.5"
},
"dependencies": {
"bulma": "^0.2.3",
"case-sensitive-paths-webpack-plugin": "^1.1.4",
"es6-promise": "^4.0.5",
"font-awesome": "^4.7.0",
"isomorphic-fetch": "^2.2.1",
"jwt-simple": "^0.5.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-pagify": "^2.1.1",
"react-redux": "^4.4.5",
"react-router": "^2.4.0",
"react-router-redux": "^4.0.4",
"react-slick": "^0.14.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"segmentize": "^0.4.1",
"slick-carousel": "^1.6.0"
},
"scripts": {
"start": "react-scripts start",
"watch": "concurrently --names 'webpack, stylus' --prefix name 'npm run start' 'npm run styles:watch'",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"styles": "stylus -u autoprefixer-stylus ./src/css/style.styl -o ./src/css/style.css",
"styles:watch": "stylus -u autoprefixer-stylus -w ./src/css/style.styl -o ./src/css/style.css"
}
}
And this is my node and npm version.
deploy#xxxx:~$ node -v
v7.3.0
deploy#xxxx:~$ npm -v
4.0.5
How can i fix this and make npm run build works?
Thanks!
I had the same problem today and I fixed it running install again.
All that you need to do is rum again the command npm install into your project so you'll be able to run npm start comand again!
Works for me!
I hope I've Helped!
When you copy a generated create-react-app project to another directory (i.e. when it was deployed to the server), it failed because symlinks were not preserved. See https://github.com/facebookincubator/create-react-app/issues/200. The file react-scripts in ./node_modules/.bin/ needs to be symlinked to ./node_modules/react-scripts/bin/react-scripts.js. Using diff will not show the differences since the symlinks will be resolved.
Easiest solution is to create a temporary react project on the server (i.e. on the Digitalocean) and then copy the content of the ./node_modules/.bin using copy -a (and not copy -r, in order to preserve symlinks).
$ create-react-app tempReact
$ cp -a tempReact/node_modules/.bin/* myActualReactApp/node_modules/.bin
Another solution is to manually re-create the symlinks.
$ ln -s myActualreactApp/node_modules/react-scripts/bin/react-scripts.js myActualReactApp/node_modules/.bin/react-scripts
Run:
sudo chown -R $USER:$USER '/home/ubuntu/.npm/'
On Linux OS NPM and NodeJS are installed globally with sudo and the owner of that files is the root and usually a user can only read/execute that packages. When NPM is stalled a ~/.npm/ folder is created by the root. By running create-react-app you are executing the command as user and create-react-app is trying to modify something in the ~/.npm/ directory which is owned by the root and not to current user. You need to change the owner of that directory to you, so you can modify it without sudo privileges.
Often similar thing happens when you install NPM package with sudo e.g. sudo npm install --save. Again the newly installed package in owned by the root and for example when you try to update/modufy/delete your project without sudo infrnt of NPM you will have similar permission error. In these cases navigate to your project directory and change its owner by running:
sudo chown -R $USER:$USER
Source: create-react-app fails with permission denied

Resources