zsh: command not found tickets (macOS) - npm

first of all, I'm not really good into this, but I installed something with npm.
npm i tickets
npm install -g tickets
Installation was succesfull and it worked fine. Afterwards, I wanted to look into the sourcecode to find sth. I needed to edit. I open the folder "tickets" into visual studio code and searched through the sourcecode but couldn't find it. Then I wanted to start it again and then it started - getting this error:
zsh: command not found: tickets
When I was working in visual studio code I was in the "tickets" directory. So, like in the beginning when It worked, I switched to home directory but I still keep getting the error. I have no idea why it doesn't work not. Basically, I did nothing except being in a different directory.
I tried to fix it with exporting the path (using a MacBook):
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/npm/bin
But did not work out.
I'm struggling now by testing out different solutions I found. Hope someone can help me out in a noob-friendly way! Thanks!

npm i installs a package in the current project. If you want it to be available from anywhere, you need to install it globally - npm install -g tickets (you'll probably need sudo in order to do that, though).

Related

Sanity not starting anymore, even though I'm in the right file

I'm making sure to type in sanity start in the right file pathway (for me its the Website folder). Its been working for me fine the past week and up till today, but not anymore. I'm worried I've messed with my Sanity files somehow, its my first time trying to use a backend so its possible I've done something I shouldn't have (I was having confusions around sanity client last night, and that my current sanity version didn't support my current react version). I think I remember trying to upgrade sanity through the terminal, but otherwise I don't remember making any other changes. I'm currently having a big issue trying to fetch data from the backend, so that's been a whole thing too.
This is the whole message I'm getting in the command prompt:
#sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`
Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "#sanity/core"
is installed as a dependency.
at _.runCommand (C:/Users/kiras/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:3608:1340)
at t.exports (C:/Users/kiras/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:1980:2422)
This is my first comment so I apologize if I'm not following some standard that StackOverFlow-culture has.
I got the same error as you, as shown below.
Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
at CommandRunner.runCommand (~/.nvm/versions/node/v18.12.1/lib/node_modules/#sanity/cli/lib/_chunks/cli-3984b311.js:17742:33333)
at Object.runCli (~/.nvm/versions/node/v18.12.1/lib/node_modules/#sanity/cli/lib/_chunks/cli-3984b311.js:17745:2460)
Yesterday everything was fine but today, Sanity was not working. I was in the right file and directory, and my JSON package was formatted properly as well. I tried installing and deleting many things but nothing worked. I ran this command in the studio directory:
sanity install
After that prompt, I got the following:
The `#sanity/core` module is not installed in current project
Project-specific commands not available until you run `npm install`
? Package manager to use for installing dependencies? npm
Then... I got a ton of "npm WARN deprecated" warnings but then I tried:
sanity start
and it worked? I hope this helps, goodluck!
If this doesn't work, make sure you have the following:
Scripts are Correct in studio/package.JSON
"scripts": {
"start": "sanity start",
"build": "sanity build"
},
If you accidentally deleted some JSON file, you can use:
npm i
to get it back, I made that mistake but make sure you're in the proper directory (web or studio).
Apologies for the long response, but this should work, a lot of the responces gave the same repetitive answer ("cd into sanity folder by writing cd sanity and then sanity start") and it frustrated me seeing the same thing 715,143,763 times lol
Good luck!

How to get the version of a remote npm package using a bin script

I'm trying to set up an npx script to create a template project.
In package.json I have:
"bin": {
"init": "bin/init"
}
In the init script I'm using tag='v'$(npm pkg get version | tr -d '"') to get the version of the package. I then use git clone --depth 1 --branch $tag https://github.com/matriarx/typescript.git to clone that specific repository for that specific tag.
When I do yarn link and try use it locally, from within that specific project, it works because it's able to correctly pick up the package.json version. So the above only works if it's run inside an existing project. However that's not what I want to do.
I want to enable someone to run it even if they have nothing locally, by simply doing npx #matriarx/typescript init and it should create the new project by cloning it. More than that I want them to be able to clone any specific version by using npx #matriarx/typescript#0.0.1 init in order to clone a specific version.
However it seems that anything I try is only able to get the version from a local package.json that already exists.
I could just clone the current existing repository without specifying any tag, but that would defeat the point of having releases, then it would just clone any current code completely disregarding the release. So it has to clone the tagged release.
How can I get the remote package version stored on npm from the bin script without having anything locally before hand?
Alternatively is there a better way to do what I'm trying to do?
EDIT: I ended up just hardcoding the version in the script, which works but it sucks because it's tedious to have to update it every time I bump the version. Though for now I still don't know a better way to do it.
After some more time messing around I figured out there is a standard way of doing it, at least since npm 7.
If you have a project like example then you can create a completely separate project called create-example with a bin script.
When you use npm init example, npm will automatically search for a package prefixed with "create-" and execute its main bin script. So when running npm init example it will search for that create-example package and execute the bin script, which will install the example package.
This is how most of the bigger packages like react and next do it.
This approach comes with some disadvantages that I really don't like, for example it will show the incorrect dependencies on npm and it will cause you to have to maintain multiple projects and semvers on different projects. However it will also allow you to create a clean separation between the actual project and the installation of that project.
For some projects it might also make a lot more sense. For example if you have a project that doesn't have a package.json at all and you want to create a setup for it, it wouldn't make sense to create an npm package inside that project just for that. Instead you can create a separate "create-project" package just to set it up and keep npm out of the actual project. In other words it gives you a neat way to create bin scripts for a completely separate project that doesn't have anything to do with npm.
You could also just have created a normal shell script and execute it using curl but I guess npm just gives you another way to do it.
You still have to hardcode the version in that "create-project" package, I still have not seen a way to automatically determine the version from a remote package. The only way I've managed to do that is to completely download the package, get the version, then delete it, but that would be terrible for people with a slower internet connection or limited data.

React Native Xcode 13.2 Error no such file or directory for NativeVibration.js

After creating the project with react-native init, i found this issue in terminal as well as in xcode. After digging deep, i found that this particular file is showing missing in project node modules.
Here are example of error codes showing in xcode & terminal-
Error: ENOENT: no such file or directory,
/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../Libraries/Vibration/NativeVibration.js
I've learned the hard way when programming in react native (for cross platform/hybrid application development), many unknown issues will be caused if you deviate from native OS clustering. Make sure you don't make the same mistakes as I have.
I have more specific help for you, apart from the obi wan style in my previously semi-answer.
Another guy had an issue with this a few years back, he asked and was answered,"delete your node_modules and app from simulator. Then re-install everything back, clear cache and see if it start bundler from root directory.
Before doing that, you can try 'react-native start' from your root directory.
I have seen that error message a lot, specifically with jest. But that's a different fix. I realize you are not using jest to test your reactjs, but it is jest tests runner that is the problem that causes the same outcome as you have come to- solution there is to disable the jest runner from running in the background while installing new packages.
I wonder if there isn't a similar solution here - only applicable to xcode - although you see it in terminal, that's probably just the cmdline not recognizing the path to the directory or at least that file.
Should be easy to figure out with terminal--
Go to $HOME~ type dir or ls, to see your directory folders, if you see the project listed, cd into it or, just search for the directory apt-get search [package] or apt, pkg, pip, pacman, snap etc etc whatever your flavor if OS terminal is, or search for the file-- $find / -iname [query] or even search for all paths containing the phrase: $locate [query]... If you created it, it exists. Just because xcode can't find it, and initial attempts in term produced nada, don't believe it is not in your system. just a matter of where, what, and why a process or dependancy is missing or malfunctioning in attempt to retrieve the file & open it.
You can definitely find it - i don't know jack about xcode, but terminal -- I can get anything from anywhere on cmdline-- you can too. I have to go, but I'm curious if you have figured it out. Let us know yeah? Best of luck to you. Cheers QwaziRidwanhasib.
-Cujo

NPM on LEMP cannot find module, wrong path

Total Linux noob here. I am trying to configure a Pleroma development environment on DO droplet. Installed LEMP, installed SSL, installed PostgreSQL, installed Pleroma, so far so good.
Then I installed Node, NPM, cloned Pleroma-FE (apparently it installs in /user/pleroma-fe folder). I am following the very brief build instructions here:
https://git.pleroma.social/pleroma/pleroma-fe
When I get to the command in those build instructions: npm run build
I am getting error: Error: Cannot find module '/user/build/build.js'
It's because actual path to the build file is /user/pleroma-fe/build/build.js
Apologies if this is a duplicate. I see other questions about this.
Fixing npm path in Windows 8 and 10
and the reply seems to set the PATH. This answer might apply to my situation. But my question is: it is clearly already looking in a well defined path (which is different from all the other questions, which don't seem to have well defined path in the error message). But it is the wrong path. How do I make it look in the correct path?
I tried the npm command and specified the complete path, and every variation. and none worked. So it seems fixing the path won't fix this problem.
Sorry I do not currently know enough Linux to be able to fix this. I tried to tag this with Pleroma but I don't have enough reputation to create a new tag. Any help is much appreciated. Thanks in advance.
I continued to work on this with some help of a Linux admin on Fiverr and the Pleroma developers chat with success, thanks to all.
The solution did not involve changing the path. There were several different things going on. First, I needed to change directory into the development project source folder:
cd pleroma-fe
Once I did that, npm found the build module. Next issue was Node was very old and I needed to get the latest version. I used the instruction here for NodeJS (10):
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Next issue was npm was missing some modules. This was fixed with:
npm install
After that the build completed with no errors.
npm run build
After a successful build, you will see a list of files that have changed as a result of the build.
Next issue is that simple changes in HTML text were not live, ie. not reflected in the refreshed web page. This is fixed by copying all the resulting build files to the production folder using rsync. In my case the command was:
rsync -av /user/pleroma-fe/dist/ /home/pleroma/pleroma/priv/static/
Pleroma is a neat Twitter-like user interface to ActivityPub fediverse, it includes a Mastodon UI as well, and thanks to the developers for making it free and open source.

Spine.js and Hem: Getting started

I successfully created a Spine app as explained on Spine's Getting started page.
However, Hem doesn't automatically take my changes into account; I have to build manually.
I have the same problem when I follow the contact screencast, but this time Hem does not build at all:
art-mac:spine.contacts art$ hem build
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Cannot find module: spine/lib/tmpl. Have you run `npm install .` ?
I did run 'npm install .'
Surprisingly, when I reinstall spine.contact (in another folder), the contacts I created in the previous contact application appear in the new application...
"Disable cash" in my Chrome development settings in is checked.
I was having the same problem when I first upgraded hem to version 0.1.9. One thing to check for is if there are compiled application.js and application.css files in the public folder of your application. It seems like when these files already exist hem server would serve those files instead of recompiling from the sources. Once those files are removed hem server would then use the source files to dynamically create the application files.
But this behavior did seem a bit different from older versions of hem. I was able to make a couple of changes to the hem server so that it seem to work as before, in that the hem server would always compile from the source files regardless if the application files already existed. I posted the code changes on a similar issue at the hem github repository https://github.com/maccman/hem/issues/46#issuecomment-6550866, but I'm not sure if its a hem issue or if something changed with the strata web server library that hem uses.
The latest Hem in npm (0.2.7) should solve this issue.
The strata server was having issues serving files dynamically if they already existed.
Hem 0.1.9 (the latest version) is not automatically detecting changes to my spine app when running "hem server"(although "hem watch" seems to be working correctly). I was able to get it working by uninstalling 0.1.9 (npm uninstall -g hem) and installing 0.1.8 instead (npm install -g hem#0.1.8).
Regarding your other issue, spine/lib/tmpl is no longer included in the latest version of spine, so if you want to use the screencast you'll need to install whatever version of spine he is using.