using Grunt with non-global installation - npm

While attempting to build a custom version of jQuery without installing global dependencies, I ran into the following issue:
$ node --version
v0.10.4
$ npm --version
1.2.18
$ git clone git://github.com/jquery/jquery.git
$ cd jquery
$ git checkout `git describe --abbrev=0 --tags` # latest tag
$ npm install
$ npm install grunt-cli
# variant A
$ npm run-script grunt custom:-ajax # does nothing
# variant B
$ node_modules/.bin/grunt custom:-ajax
Running "custom:-ajax" (custom) task
Creating custom build...
Warning: Error: not found: grunt Use --force to continue.
Aborted due to warnings.
I haven't worked with Grunt or Node much before, so what am I missing here?

This is because of how the jQuery custom task spawns grunt. I've just sent a pull request which would fix this issue: https://github.com/jquery/jquery/pull/1255

Related

How can I set the npm version in gitlab CI?

I have a gitlab pipeline for an Angular project with the image in .gitlab-ci.yml
image: node:16
build:
stage: build
script:
- npm ci
- nodejs -v
- npm -v
- npm run build:prod
- npm doctor
When the pipeline reaches the npm doctor it fails with the following error on npm version:
$ npm doctor
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v7.24.0
node -v ok current: v16.9.1, recommended: v16.9.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /usr/bin/git
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 1361 tarballs
How can I solve this?
In my machine I have the npm version v7.24.0 and the command succeeds.
Install npm before you do anything else, specifying a version, i.e. npm install npm#version -g.
For completeness, if you can't update the global npm, you can do so locally, by replacing npm with npx npm#latest or npx npm#7.24.0. npx will install npm if it needs to, locally, and then run the local installation.
Lastly you can install locally with npm install npm#latest and then run it with $(npm bin)/npm, but this is what npx is for.
Note that I don't understand why you're running npm doctor after a build. Presumably if you care about npm thining it's set up properly you should run it before the build, so the pipeline fails early.
P.S. I stupidly read 'github' as 'gitlab'. If you were using github I would recommend using
setup-node if only for dependency caching, which can seriously speed up pipelines. I don't know if gitlab does anything similar.

How to install yo on node#12 and npm#6.9.0 with zshrc via homebrew

I have been trying to install yo to integrate and test botkit but had issues with yo and npm and node as I updated brew on my mac to the latest. Here is how I resolved it.
If you have installed latest node 12 on your mac using latest update of homebrew(if you haven't updated and want to, please update brew by running brew update and run brew install node).
Run the following commands to verify node and npm are updated to 12 and 6.9.0
[keshav#xxxxxx-mbp ~ ]$node -v
v12.1.0
[keshav#xxxxxx-mbp ~ ]npm -v
6.9.0
If this is what you see on your console, you are good to proceed to next steps.If not, please add a comment if you are facing a error.
Run the following commands
echo export PATH="$HOME/npm/bin:$PATH" >> ~/.zshrc
npm config set prefix ~/npm
echo "export NODE_PATH=$NODE_PATH:/home/$USER/npm/lib/node_modules" >> ~/.zshrc && source ~/.zshrc
npm install -y -g yo
Once you run the command in step 4, you should see the below output in the console.
Output of command 4
npm install -y -g yo
npm WARN deprecated cross-spawn-async#2.2.5: cross-spawn no longer requires a build toolchain, use it instead
/Users/xx/npm/bin/yo-complete -> /Users/xx/npm/lib/node_modules/yo/lib/completion/index.js
/Users/xx/npm/bin/yo -> /Users/xx/npm/lib/node_modules/yo/lib/cli.js
yo#2.0.6 postinstall /Users/xx/npm/lib/node_modules/yo
yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ NODE_PATH matches the npm root
✔ yo version
Everything looks all right!
+ yo#2.0.6
updated 1 package in 5.752s

Yocto recipe fails to install npm package

I have a recipe that installed some NPM packages that worked on an older version of Yocto.
After upgrading to sumo, the recipe fails with the following error:
installnpmpackages/0.0.1-r0/temp/run.do_compile.7272: npm: not found
| WARNING: exit code 127 from a shell command.
I tried using the developer shell and NPM does work in that case.
The do_compile from the recipe:
do_compile() {
# Create a working directory
mkdir -p ${WORKDIR}/scratch
# changing the home directory to the working directory, the .npmrc will be created in this directory
export HOME=${WORKDIR}/scratch
# configure cache to be in working directory
npm set cache ${WORKDIR}/scratch/npm_cache
# clear local cache prior to each compile
npm cache clear
# compile and install node modules in source directory
cd ${WORKDIR}/scratch
npm --arch=${TARGET_ARCH} --verbose install node-gyp
npm --arch=${TARGET_ARCH} --verbose install connect
npm --arch=${TARGET_ARCH} --verbose install socket.io
#npm --arch=${TARGET_ARCH} --verbose install sqlite3
#npm --arch=${TARGET_ARCH} --verbose install serialport
npm --arch=${TARGET_ARCH} --verbose install express
npm --arch=${TARGET_ARCH} --verbose install csv
npm --arch=${TARGET_ARCH} --verbose install md5
# clear local cache before we package. No need to copy over all this cache stuff; just need the modules.
npm cache clear
}
Note sqlite3 and serialport are commented out as they did not work on the previous version.
What needs to be changed with sumo (vs morty) for NPM to function in a recipe?
Thank you in advance!
I found a simple solution.
I created individual recipes using devtool add.
Here is the command used to create a recipe for the serialport npm module:
devtool add "npm://registry.npmjs.org;name=serialport;version=7.1.4"
I'm answering to #Hsn comment as my account is new and I don't have 50 reputation.
If you are able to add a recipe with devtool and it worked, you can use devtool as well to finish working on the recipe and tell devtool in which meta you want to put the recipe like :
devtool finish recipe_name meta-destination
And in order to put it into your final OS rootfs, you need to add it to your image bb file, for example : image-dev.bb :
IMAGE_INSTALL_append += "recipe_name"
Make sure also that the meta which holds your recipe is present in your bblayers.conf.

running vue documentation locally

i was trying to run vuejs documentation offline (locally) and had no lack, it worked in the past but i don't know what i have done wrong.
i followed the steps on the following post
hear
basically the steps are
install hexo-cli globally
npm install hexo-cli --global
clone vuejs.org repository
git clone https://github.com/vuejs/vuejs.org.git
install project dependencies
cd vuejs.org && npm install
run local server using npm or hexo
npm start
i keep gett
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: watch /vuejs.org/themes/vue/layout/icons/ltc.ejs ENOSPC
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1374:19)
at Object.fs.watch (fs.js:1400:11)
at createFsWatchInstance (/vuejs.org/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/vuejs.org/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/vuejs.org/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/vuejs.org/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/vuejs.org/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:153:5)
You ran out of watchers. Proper solution would be to find out why that happened, however you can simply raise available amount of watchers.
fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
or remove files that are watched but aren't needed, for example some unused templates or assets.
You can find more options here:
Node.JS Error: ENOSPC

Babel Errors in Cloud 9 IDE

Getting a bunch of babel errors when running npm run dev with the Vue cli.
This only happens in Cloud9.
Any thoughts on what could be the issue or how to disable errors like this before running npm run dev?
All babel related it looks like.
I couldn't re-create the babel error messages but it's possible that it could be caused if npm/node is not up-to-date. (Vue-cli wasn't starting dev server before the installation below)
Is your repository public where you're getting the error messages? Then I could have a look at the errors.
If removing node_modules folder is not helping,
here is how you can create a new IDE workspace for vue.js ($ for commands in bash terminal):
Create a blank Ubuntu workspace
Check that nvm is installed & up-to-date with (check version of install script here):
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
$ nvm install node 6
$ npm i vue-cli -g
$ vue init webpack yourAppName
$ cd yourAppName
$ npm install
$ npm run dev
Click preview to test that Vue server is running as expected
Here is a link to a HelloWorld Vue app in cloud9 ide.
If you have an existing app you can also use git to clone it into your new workspace instead of creating a new app.