Command "rm" not found - angular5

I am trying to remove my node_modules using yarn in my angular 5 project. i am running the command "yarn rm -rf node_modules" , this is showing the error "command rm not found".

Related

npx but use version in package json

I have a build script in javascript project that uses parcel to iterate through folders and finding index files and then building those projects. When I find an index file I run this command:
npx parcel build ${indexFilePath} --out-dir ${outDir} --target node
But, if the person running this build script has not installed packages with npm i yet, the npx command will install the latest version of parcel-bundler, where --out-dir is now deprecated and breaking the entire script.
Here is what's going on, distilled:
$ rm -rf node_modules
$ npm i
$ npx parcel --version
1.12.4
$ rm -rf node_modules
$ npx parcel --version
2.0.0-beta.2
Is there any option for npx to use the version in the package.json file that is already in the project and install it to node_modules? Or do I just ingrate the install step into my build? It just seems overkill, since all I need to build is parcel.
Am I abusing npx by using it like this?
Multiple issues exist in npx regarding this problem : #199 & #15
The only option I found so far was to parse & extract version from my package.json using node repl (which should be available in your case)
Something like this :
npx parcel#`node -p -e "require('./package.json').dependencies['parcel']"` --version

Run yarn from Dockerfile in ddev

This is a followup to How can I add and use nvm in a DDEV web container?
My dockerfile now looks like this:
ARG BASE_IMAGE
FROM $BASE_IMAGE
ENV NVM_DIR=/usr/local/nvm
ENV NODE_DEFAULT_VERSION=v8.16.1
RUN curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh -o install_nvm.sh
RUN mkdir -p $NVM_DIR && bash install_nvm.sh
RUN echo "source $NVM_DIR/nvm.sh" >>/etc/profile
RUN bash -ic "nvm install $NODE_DEFAULT_VERSION && nvm use $NODE_DEFAULT_VERSION"
RUN chmod -R ugo+w $NVM_DIR
RUN npm install -g foundation-cli
RUN npm install -g gulp-cli
RUN yarn --cwd foundation-src install
The last line returns an error: Service 'web' failed to build: The command '/bin/sh -c yarn --cwd foundation-src install' returned a non-zero code: 1'
When I ddev ssh and then run yarn --cwd foundation-src install it does the job (running yarn in the foundation-src folder).
I also tried RUN (cd foundation-src; yarn install;) but no luck either. I prefer the first command anyway. But what is going on? Why can I run stuff from inside the container but not from the dockerfile?
Your command is RUN yarn --cwd foundation-src install - it's assuming that there is a subdirectory "foundation-src" under the current directory.
But the Dockerfile is running long, long before your source is anywhere useful. The container has not been run yet, nothing is mounted. So you can't do things that require your source code to be present.
Since this command appears to require your source code to be present, I think you'll be better doing this as a post-start hook, perhaps
hooks:
post-start:
- exec: "yarn --cwd foundation-src install"
Since actions like yarn install happen irregularly, it's also easy to ddev exec yarn --cwd foundation-src install and also easy to create a custom command to do that when you need it.

Entry, ":CFBundleIdentifier", Does Not Exist in new react native project

I created a new project with the command react-native init LocationExample --version 0.57.7
It created a project named LocationExample but when I further went into project folder and ran the command react-native run-ios.
This gave an error stating Entry, ":CFBundleIdentifier", Does Not Exist
I have tried removing the build folder by running command rm -rf ios/build and also tried removing the mode modules by rm -rf node_modules. After which i ran yarn command to install the node_modules again but, this had no effect.
Edit1:
/Users/apple/React Native/LocationExample/node_modules/react-native/scripts/ios-install-third-party.sh: line 56: /Users/apple/React/ios-configure-glog.sh: No such file or directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
Also this error
'glog/logging.h' file not found
Expected: App should be installed and should run successfully.
Actual: App is not installed and states the error of BundleIdentifier.
Build it in Xcode. If the build is successful then run it in Xcode using Cmd+R
EDIT
Try this
1- Changing the bundle identifier.
2- Adding package:
yarn add #babel/runtime
3-
watchman watch-del-all
4- Removing the build:
rm -rf ios/build
5-
sed -i '' '/DevelopmentTeam = V9WTTPBFK9/d;/DEVELOPMENT_TEAM/d;/ProvisioningStyle = Automatic/d' ./node_modules/react-native/React/React.xcodeproj/project.pbxproj
6-
react-native start --reset-cache
7-
react-native run-ios

Clean react native project

How to clean react native project?
Is there any way to clean react native project as we can clean xcode project?
Any help will be appreciated!
A react-native Project is about one XCode Project and one Android Project. (for pure js code, there's no need to do clean)
So, what you need would be
Clean XCode Project with
cd ios
xcodebuild clean
And then clean Android Project with
cd android
./gradlew clean
You can simply write a batch file for it.
For android project
cd android &&./gradlew clean && cd ../
For iOS project
cd ios && xcodebuild clean && cd ../
If you need build clean again and again then add this scripts in the package.json file like this
scripts: {
"clean:android": "cd android && ./gradlew clean && cd ../",
"clean:ios": "cd ios && xcodebuild clean && cd ../",
}
Then run for android
yarn clean:android
And run for iOS
yarn clean:ios
For Android
cd android
gradlew clean
For IOS
cd ios
xcodebuild clean
Delete node modules and
npm ci
react-native link
followed by
react-native start --reset-cache
React Native clean-project is now the best and easiest way to do deal with react-native artifacts and cleanup. Since it's automatically detected by react-native, it becomes its own command in react-native.
$ yarn add -D react-native-clean-project
$ react-native clean-project
this script will clean the Android and IOS build cache, then removes node modules and caches, and reinstall the react native project.
# rm -rf $HOME/.gradle/caches/
cd android && ./gradlew cleanBuildCache
cd ..
cd ios && pod cache clean --all && rm -rf build
cd ..
rm -rf node_modules
yarn cache clean --force
yarn install
cd ios && pod install
To reset the iOS simulator and erase all simulator data, focus on the simulator then go to Hardware -> Erase All Content and Settings
To reset the Android emulator and erase all data, open Android Studio then goes to menu Tools -> AVD Manager, then click the dropdown menu on the selected simulator and click on wipe data.
More useful cleaner scripts. Seperating modules cleaning & native cleaning, based on the other great answers:
"scripts": {
"npm:clean": "rm -rf node_modules && npm cache clean && npm install"
"yarn:clean": "rm -rf node_modules && yarn cache clean --force && yarn install"
"android:clean": "cd android && ./gradlew clean && ./gradlew cleanBuildCache && cd ..",
"ios:clean": "cd ios && xcodebuild clean && rm -rf ~/Library/Caches/CocoaPods && rm -rf Pods && rm -rf ~/Library/Developer/Xcode/DerivedData/* && pod cache clean --all && pod deintegrate && pod setup && pod install && cd ..",
}
To reset react-native specific cache, run:
npm start -- --reset-cache
if in package.json you have
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
}
I added the following scripts to my package.json
scripts: {
....
"clean:android": "echo 'require(\"child_process\").execSync(\"cd android; ./gradlew clean\", {stdio: \"inherit\"})' | node ",
"clean:ios": "echo 'require(\"child_process\").execSync(\"cd ios; xcodebuild clean\", {stdio: \"inherit\"})' | node ",
"clean": "npm run clean:android && npm run clean:ios",
....
}
now you can clean android
npm run clean:android
clean ios
npm run clean:ios
clean both
npm run clean
React and node specific cleaning:
Remove node_modules to avoid inconsitence which may appear somehow rarely:
rm -rf node_modules
(reinstall if need with npm or yarn)
Clean npm cache if npm is used
npm cache clean
Clean react temp files:
rm -rf $TMP/react*
Clean the Android Project with:
cd android/
gradlew clean
remove android folder
run
react-native upgrade
then
react-native run-android

Why does "yarn install" raise an ENOENT error when installing esparse?

I have a JavaScript project using npm to manage its dependencies. I'm trying to migrate to Yarn.
When I run yarn install in the console, it gives me an error:
An unexpected error occurred: "ENOENT: no such file or directory,
chmod C:\....\node_modules\.bin\esparse"
From what I read on the yarn docs, just running yarn install should be enough. Why doesn't this work as expected?
I am using Yarn 0.17.0, npm 2.14.12 and Node 4.2.4.
The following Solution worked for me
rm -rf node_modules **/node_modules
rm -rf yarn.lock **/yarn.lock
yarn cache clean
yarn install
This is a pretty old question, but with latest yarn for now (1.17.3) the same problem arises.
The solution which works for me, although more time consuming, is to delete yarn.lock file.
Please keep in mind that afterward, all libraries will get updated to the latest versions according to the rules you specified in package.json file
I had a similar issue which was resolved by running the following commands:
npm install yarn -g --force
yarn --c
rm package-lock.json
rm yarn-lock.json
yarn install