Using Sails.js with yarn - sails.js

When I run sails new myapp it generates a package.json file and a /node_modules directory. The sails docs say to cd in and run npm install to get up and running.
I've recently started using yarn and would like to use it to manage the additional dependencies I add to my sails app. However, when I run yarn init (what I think creates the yarn.lock file) it looks like it wants to create my package.json again. And it errors on the entry point question, saying Cannot convert object to primitive value.
Should I just stick to vanilla npm? Can Yarn and Sails play nicely in the sandbox together and share the toys?

In fact, $ yarn init (as well as $ npm init) will just initialize your package.json file by asking a few questions.
Here you don't need to regenerate your package.json but just install your node modules and generate a yarn.lock file to lock your modules versions. You can do this by using $ yarn install or just $ yarn.

You can skip $ yarn init as it does the exact same thing as $ npm init. $ yarn install actually creates the yarn.lock file. Unlike npm, yarn actually respects the engines property in a package.json file. If you run into this you can use $ yarn install --ignore-engines.

Related

npx hardhat doesnt creates a new project

I tried creating a new hardhat project. I tried the following commands in terminal.
npm init --yes
npm install --save-dev hardhat
But when I use the following command
npx hardhat
I am getting the following
I think hardhat have changed the contents. Couldnt find anything in the official document.
Can someone suggest how to create a new project using hardhat.
Edit: Contents of the folder
run
$ npx hardhat --verbose
You will get the location of a hardhat config file like this:
$ hardhat:core:config Loading Hardhat config from /home/lyon/hardhat.config.js +0ms
Delete it and run npx hardhat again
That happens when you are trying to create a hardhat project inside a hardhat project. The same happened to me and I realized that in the parent directory I already had hardhat.config.js file. I had to remove that config file.

Installation of protoc-gen-grpc-web

I am currently working on using grpc-web to write a simple client for my service. I have created a service.proto file which was successfully compiled using protoc. The problem arose when I tried to generate the gRPC-Web service client stub using the plugin protoc-gen-grpc-web which doesnt work despite having installed the latter.
Got the following error :
protoc -I=./ service.proto --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./
protoc-gen-grpc-web: program not found or is not executable
--grpc-web_out: protoc-gen-grpc-web: Plugin failed with status code 1.
Any suggestions on how to solve this issue? Thank you!
You'll need to make the protoc-gen-grpc-web plugin executable and move it to a directory that is discoverable from your PATH environment variable.
From grpc-web/README:
For example, in MacOS, you can do:
$ sudo mv ~/Downloads/protoc-gen-grpc-web-1.2.1-darwin-x86_64 \
/usr/local/bin/protoc-gen-grpc-web
$ chmod +x /usr/local/bin/protoc-gen-grpc-web
You don't even have to install the plugin globally and make it discoverable from your PATH:
protoc accepts --plugin arguments to point to a required plugin. For protoc-gen-grpc-web (as for many others) there's even npm support, so you can get it with npm i --save-dev protoc-gen-grpc-web and then run protoc with --plugin=protoc-gen-grpc-web=./node_modules/.bin/protoc-gen-grpc-web
I'm using MacOS. You need to install this first with brew
$ brew install protoc-gen-grpc-web
The best solution that I could use for Linux based system was globally installing protoc-gen-grpc-web. This directly takes the files from the /bin of the node_modules files created globally across your system
sudo npm install -g protoc-gen-grpc-web

ERROR:The serve command requires to be run in an Angular project, but a project definition could not be found

I am trying to clone the git repository for Tour of Heros with NgRX (blove/ngrx-tour-of-heros)
However, I can not seem to run the application.
I have updated my Angular cli to 7.3 I have installed yarn to try and help as well as tried to create a new application and remove files to drag and drop files that where not there like the node modules, and I am still getting this error.
How do I get this error removed so that I can see the file?
Check your build per-requisites, as illustrated by blove/ngrx-tour-of-heros issue 2
Breaking changes - node => 10
ERROR - "json-server requires at least version 4 of Node, please upgrade"
if your node -v is greater than 10, npm upgrade json-server
Appears that node-sass was optional on yarn install.
Had to install separately - yarn add none-sass
Also, cd client and cd server are reversed in lines 13 and 15.
The angular project is in de client directory, so after cloning the repo you have to get into the client directory before running the ng serve command:
git clone https://github.com/blove/ngrx-tour-of-heros.git
cd ./client
yarn install
npm run start
Seems like it's an older repo with Angular v5 and CLI v 1.6 - try downgrading if it doesn't work. https://github.com/blove/ngrx-tour-of-heros/blob/master/client/package.json#L32

yarn - What does #npm mean?

I know that running yarn add package#1.2.3 would install package v1.2.3.
I recently encountered this syntax: yarn add package#npm. What does #npm do? Is it a special sign for yarn or is it specific to that package (material-ui)?
I encountered #npm as a solution to include two versions of material-ui by aliasing the next version: yarn add material-ui-next#npm:material-ui#next
No real surprises, it is a directive to install a specific package from npm.
yarn add {package1} installs the specified package from the npm registry by default.
yarn add {package1}#npm:{package2} installs package2 from the npm registry and assigns package1 as its alias.
It makes no difference if a package named package1 exists in the npm registry, it will only download the package you've specified with the #npm directive.
From your question, it seems like you've already got a handle on this one.

Ionic 1.x - from bower to npm

I used to install plugins in my ionic 1 project with bower. The new trend, especially with ionic 2, is to install packages with npm. Some core packages, such as ionic.cloud are not provided at all anymore with bower, even for ionic 1.x.
So I need to migrate some packages to npm. What is the recommended way to do so ?
My problem:
"npm install" seems to install packages in the "my_project/node_modules" folder, unlike bower which installs packages directly in my_project/www/lib/
As explained for instance in the installation guide of ionic.cloud this requires an additional step to copy the newly installed npm package in the lib folder with the command:
cp node_modules/#ionic/cloud/dist/bundle/ionic.cloud.min.js www/lib
However, when I update the package and run "npm update", this will update the node_modules folder, but not the lib folder. This is a problem as only the files from my lib folder are included in my index.html.
Running the cp-command after each npm update does not seem such an elegant solution. What is the recommended way to deal with this?
I think you can reverse this make the .bowerrc file create your packages inside the node_modules folder and use this path as default. Otherwise the node_modules is mandatory there is no way around creating it.
Even you can npm i --prefix ./bower_components/ <package> you still need to cp to folders up from bower_components folder