I have the following directory structure for a project I'm working on:
application
package.json
client
package.json
server
package.json
Additionally, some of the dependencies used in the project have a similar client/server hierarchy with a base-level package.json. The reasoning here is beside the point. What I'm trying to do is find the installed version(s) of a given lib within this project wherever it may be getting pulled in. I had hoped npm ls would do this, but it appears to only inspect the base-level package.json files.
I'm considering writing a bash script or something that recursively finds all node_modules directories starting in the root directory and then using npm ls in each directory, but am also hoping to find an easier answer. Any thoughts would be appreciated.
I ended up defining an alias as follows:
alias npm-ls-lib='_npm-ls-lib(){ \find . -type d -name "$1" -exec npm --prefix {} ls . \; | grep -v \(empty\); }; _npm-ls-lib'
and now I can call it like this: npm-ls-lib lib-name
Related
I am complete beginner so I apologize in advance.
I have installed npm with these scripts in terminal
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
then I set it to run like this
http-server -a localhost
Starting up http-server, serving ./public
Available on:
http://localhost:8081
an I have an index. html in my documents that I would like to display. I have tried to just state the whole path in the browser so like http://localhost:8081/Documents/testServer/index.html
But that doesn't work
You must install the tools inside the folder that contains index.html file as below
First : Open the folder that contain index.html
Second : Install Tools
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
Third : Open the live server at :
http://localhost:8081/Documents/testServer/index.html
Autocomplete started working bad after upgrading from ubuntu 16. If I hit tab after
git checkout src/
I get something like this:
$ git checkout src/bash: cd: too many arguments
main/ test/
Coincidentally I happened to see the same using the "test" command of gnu-coreutils:
$ ls
pom.xml src target
$ test pom.xml
bash: cd: too many arguments
Are the two things maybe connected? Unfortunately I couldn't find any bug after googling it.
I had the same issue. One of my aliases had the name test, lib or root (I don't remember which one) and it was a cd command to a folder. Renaming the alias solved the problem for me.
My latest alias with .bashrc was with using words like test and git where I was trying to change to corresponding directories. I have changed them to testdir and gitdir and restarted my computer. I don't have this -bash: cd: too many arguments error showing up now.
I'm trying to use the NPM copyfiles package, which I used many times. But I'm trying to copy the content of a dist folder in a destination folder without creating a dist but I can't find the correct way of doing it. I basically just want the content of the dist (not the folder in itself).
So what I have is
-- dist
|
-- bundles
-- lib
package.json
I want this result
-- destination
|
-- bundles
-- lib
package.json
but I always get the dist in the destination which is unwanted
-- destination
|
-- dist
|
-- bundles
-- lib
package.json
I tried
cross-env copyfiles dist/**/*.* ../dest
I also tried with the --up 1
cross-env copyfiles --up 1 dist/**/*.* ../dest
The only thing that works is with the -f (flatten) flag but I lose the folder structure.
cross-env -f copyfiles dist/**/*.* ../dest
Am I missing something or is it just not possible?
Firstly, given the examples shown in your question there is no need to use copyfiles with the additional package cross-env. The package copyfiles will work cross platforms.
cross-env is used for setting and using environment variables, e.g. NODE_ENV=production.
Using the --up 1 argument, (or its shorthand equivalent -u 1), with copyfiles is the correct way to omit the dist directory. So just use the following instead:
copyfiles --up 1 dist/**/*.* ../dest
I.e. remove the initial cross-env part to resolve the issue.
Got this working with ncp npm package.
ncp ./dist/ dest --filter **/*.*
When creating a react-native app with react-native init MyApp the Android and iOS package names are automatically set to com.myapp.
Changing the Android package name (especially if you need something longer like com.organisation.propject.app) later in the development is pretty fiddly and I was wondering if there was a way to set the package name when setting up a project with react-native init?
Note: it's working only in RN 0.37 and maybe one or two versions up, in 0.40+ this feature was removed.
You need to specify a --package option:
$ react-native init MyApp --package=com.organization.project.app
The below worked for me. Substitute your own app name for "Foo App" and your own package name for org.newpackage.app.
NEW_APP_NAME="Foo App"
NEW_PACKAGE_NAME=org.newpackage.app
OLD_PACKAGE_NAME=org.reactjs.native.example
npx react-native init rndemo && \
cd rndemo && \
npx react-native-rename "${NEW_APP_NAME}" -b ${NEW_PACKAGE_NAME} && \
rm -rf ios/Pods && \
pod install --project-directory=./iOS && \
grep -rl ${OLD_PACKAGE_NAME} * | \
xargs sed -i '.bak' "s/${OLD_PACKAGE_NAME}/${NEW_PACKAGE_NAME}/g"
I've created a gist that does this, prompting interactively for the app name and package name. The gist is a tiny bit more sophisticated, in that (in the above example) it would initially create the app fooapp instead of rndemo.
Explanation:
Create a react-native app. It's called rndemo temporarily; we need to know what it's going to be called so we can change to it.
Run react-native-rename to rename the new project to whatever you specified; this lets us replace the package name too.
Remove the installed cocoa pods and reinstall them (so they'll pick up the new folder locations etc).
Search for the default package name org.reactjs.native.example and replace it with your new package name. Currently this will only find ios/FooApp.xcodeproj/project.pbxproj. The old project.pbxproj file will be saved with a '.bak' extension. This step would probably be better done with find . -name project.pbxproj -exec ..... but this was good enough for my needs.
I have a problem with the global environmental variable CMAKE_PREFIX_PATH. I already set this and I can see it is set when I type env, but when I run cmake . to build HipHop, it tells me that the variable isn't set.
Is there a way I can hard-code this into the makefiles?
Try to run cmake -DCMAKE_PREFIX_PATH=/your/path .
CMAKE_PREFIX_PATH works as a build directive, rather than as an environment variable. Moreover, you may perform the build into a dedicated temporary directory (it's cleaner, because when done, you can remove that temporary directory and you get back a clean pristine source tree).
$ mkdir -p tmpbuild && cd tmpbuild
$ cmake -DCMAKE_PREFIX_PATH=~/deliveries/hiphop ..
$ make install
$ cd ..
On MacOS it's different. I had to use:
make -i CMAKE_PREFIX_PATH="/the/path"
This was while installing VMQT, and this error was shown:
CMake Error at CMakeLists.txt:87 (find_package): By not providing
"FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has asked CMake
to find a package configuration file provided by "OpenCV", but CMake
did not find one.
Could not find a package configuration file provided by "OpenCV"
with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If
"OpenCV" provides a separate development package or SDK, be sure it
has been installed.
Used this to solve it: make -i CMAKE_PREFIX_PATH="/opt/homebrew/Cellar/opencv/4.6.0_1/lib/cmake/opencv4/"