Installing bootstrap with npm is failing - node.js

I am attempting to install bootstrap (LESS) with npm on Debian but it keeps failing.
This is exactly what i am doing:
git clone https://github.com/twbs/bootstrap.git
npm install
The error i get is simply Killed.
Running the npm install in verbose i do not get any error:
npm verb readDependencies using package.json deps
npm http GET https://registry.npmjs.org/postcss/-/postcss-2.2.5.tgz
npm info retry fetch attempt 1 at 01:00:50
npm verb fetch to= /tmp/npm-3690-Rr0nZSRK/registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000010.tgz
npm info postinstall ansi-regex#0.2.1
Killed

npm install
simply installs the upstream dependencies based on what is listed in the package.json in your current directory
Try this
git clone https://github.com/twbs/bootstrap.git
cd bootstrap
npm install # installs dependencies
npm install -g bootstrap # does actual install of bootstrap into module dir
note the -g in the install command puts bootstrap into your global npm module directory
as defined by environment variable $NODE_PATH

You can also low down memory consumption by "npm config set jobs 1", did work for me ;) link: https://community.c9.io/t/npm-install-is-killed/847

Related

Error while building simple API with AWS CodePipeline, CodeBuild

I have been attempting to set up auto-deploy from my github repo for this simple REST API and cannot get it to stop erroring on 'npm install'. It is your basic node project with express. Here is my buildspec.yml:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- echo Installing
pre_build:
commands:
- echo Installing source NPM dependencies.
- npm install
build:
commands:
- echo Build started on `date`
- echo Compiling the Node.js code
- npm run build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'
Here is the error prinout from AWS CodeBuild:
[Container] 2022/05/15 21:13:45 Running command npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2. I'll try to do my best with it!
npm WARN wts_api#1.0.0 No description
npm WARN wts_api#1.0.0 No repository field.
npm ERR! code EEXIST
npm ERR! path /codebuild/output/src331276253/src/node_modules/.bin/nodemon
npm ERR! Refusing to delete /codebuild/output/src331276253/src/node_modules/.bin/nodemon: is outside /codebuild/output/src331276253/src/node_modules/nodemon and not a link
npm ERR! File exists: /codebuild/output/src331276253/src/node_modules/.bin/nodemon
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-15T21_13_48_178Z-debug.log
[Container] 2022/05/15 21:13:48 Command did not exit successfully npm install exit status 1
[Container] 2022/05/15 21:13:48 Phase complete: PRE_BUILD State: FAILED
[Container] 2022/05/15 21:13:48 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install. Reason: exit status 1
I think I've done this 100% as convention dictates, except for maybe my project structure. Rather than having all my files in 'src', they are in the root of the project.
Maybe you found the answer already, but for future readers, here it goes:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2. I'll try to do my best with it!
According to this message, the reason why the install fails is because you used different versions of npm on local machine vs on codebuild.
Your codebuild is using nodejs: 10 runtime, so according to the screenshot below (taken from https://nodejs.org/en/download/releases/), it must be using npm v6.8.x that comes with that version of node.
That version of npm generates/reads package-lock.json file with a version 1 format, while your local npm has generated a package-lock.json with the version 2 format, most certainly because you are on npm v7 or later.
Solution:
Update npm version in the pre-build phase of your Codebuild, as such:
pre_build:
commands:
- echo Installing source NPM dependencies.
- npm install -g npm#<your_local_version_here>
- npm ci
Also, it better to use npm ci rather than npm install on CI, because the former leverage the existing package-lock.json to ensure reproductible builds.

how to download node modules to Angular 2 project

I have git project downloaded in dir d:/myapp. I have npm 3.10.10 and node 6.11 install on my windows machine. But while runnning Install npm from git bash commd line to install all dependent node module...i get error as below:
$ install npm
install: missing destination file operand after 'npm'
Try 'install --help' for more information.
The command to install npm modules is just npm install. It looks you are doing install npm install, with an extra "install" before npm.
Here are the official docs for npm install showing the different options. Note that npm is always the first command for any npm commands, whether it's install, start, etc.

Local grunt installation gives error

npm install -g grunt-cli //done successfully
npm install grunt --save --only=dev
gives following error
(node:11000) fs: re-evaluating native module sources is not supported. If
you are using the graceful
-fs module, please update it to a more recent version.
npm WARN prefer global coffee-script#1.10.0 should be installed with -g
project#1.0.0 C:\Users\Live\Desktop\node grunt\final
`-- (empty)
npm WARN project#1.0.0 No repository field.
npm ERR! code 1
Tried uninstalling grunt-cli, cleaning npm cache, then re-installing, but still the problem persists.
Ok short recap:
When in doubt remove your node_modules and install all packages again using npm install
If that didn't work, try updating your npm by executing npm update -g npm and redo step 1.
If that didn't solve your problem, try upgrading to another NodeJS version using nvm or n.

Install node module from own gitlab server

I'd like to install node modules from our gitlab server. This is a link to a repository:
http://ABCD-GITLAB/myGroup/myNodeModule.git
According to the npm install guide the install command should be this:
gitlabUser: me
myProject: myNodeModule
npm install gitlab:mygitlabuser/myproject
I have no idea how to reference my
gitlab server url
group
project
account name
I tried some commands but all failed:
npm install gitlab:ABCD-GITLAB:me/myproject
npm install gitlab:ABCD-GITLAB:me/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myproject
npm install gitlab:http://ABCD-GITLAB:me/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject.git
What is the correct way to reference a npm dependency, a clear structure would be great like
npm install gitlab:<serverUrl/>:<username/>/<groupname/>/<projectname/><gitsuffix>.git
I would try one of these:
npm install git+ssh://git#ABCD-GITLAB:myGroup/myNodeModule.git
npm install git+https://git#ABCD-GITLAB/myGroup/myNodeModule.git
npm install git://ABCD-GITLAB/myGroup/myNodeModule.git
You may need to change git to your username and you can add #v1.0.27 or something like that at the end for a specific version or tag:
npm install git://ABCD-GITLAB/myGroup/myNodeModule.git#v1.0.27
You can also install from a tarball:
npm install https://ABCD-GITLAB:myGroup/myNodeModule/repository/archive.tar.gz
You can add ?ref=master to the end of the tarball URL for the branch.

Using NodeJs' Grunt on code that is developed on Windows and built on Linux?

How to use nodejs to build a cross platform project?
I develop on Windows, but my codebase builds on a Linux-based CI server. It uses Grunt to build the frontend, and requires several nodejs modules for that.
Nodejs requires modules to be installed locally to the project in order for the to be loaded by grunt.task.loadNpmTasks. The issue with that is that I have to install them from somewhere, either Windows or Linux, and when I do from one it doesn't work on the other.
The list modules my project require are installed locally as follows:
npm install connect-livereload --production
npm install time-grunt --production
npm install load-grunt-tasks --production
npm install jshint-stylish --production
npm install load-grunt-tasks --production
npm install grunt-contrib-copy --production
npm install grunt-contrib-concat --production
npm install grunt-contrib-uglify --production
npm install grunt-contrib-compass --production
npm install grunt-contrib-jshint --production
npm install grunt-contrib-cssmin --production
npm install grunt-contrib-connect --production
npm install grunt-contrib-clean --production
npm install grunt-contrib-htmlmin --production
npm install grunt-contrib-imagemin --production
npm install grunt-contrib-watch --production
npm install grunt-rev --production
npm install grunt-usemin --production
npm install grunt-mocha --production
npm install grunt-exec --production
npm install grunt-open --production
npm install grunt-svgmin --production
npm install grunt-concurrent --production
npm install grunt-ember-templates --production
npm install grunt-replace --production
npm install grunt-neuter --production
If I install it from Windows and then run grunt on the project folder from Windows still it all works perfectly. If I then check the code into git and build in the linux box, chmod 777 and chown to my user, and run the same grunt command. It fails with a lot of errors like these:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
Fatal error: spawn ENOENT
I ran npm install and it starts failing with another message:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
/home/administrator/platform/frontend/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
throw err;
^
Error: spawn ENOENT
at errnoException (child_process.js:998:11)
at Process.ChildProcess._handle.onexit (child_process.js:789:34)
Nothing I do makes it work.
So from the Linux box I deleted the whole node_modules directory from my project and rerun the install commands above. All works perfectly on Linux now.
Then I check it into git and checkout in Windows. Then I go to the project folder and run grunt, and then it fails with:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
Running PhantomJS...ERROR
>> 'c:\Users\Edy' is not recognized as an internal or external command,
0 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>> 'operable program or batch file.' ]
>> operable program or batch file. 1 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>> 'operable program or batch file.' ]
Warning: PhantomJS exited unexpectedly with exit code 1. Use --force to continue.
Uninstalling phantomjs and installing it locally doesn't help. Installing globally doesn't help either. So the only way to make it work on Windows seems to be deleting the node_modules dir and reinstalling on Windows, which brings me to the first issues on Linux.
Is there a way to use nodejs stuff in a cross platform environment like mine? I cannot believe I'm the first one with such a setup out there hehe
Any tips or help in this is appreciated. Thanks!
Many dependencies in node.js use native addons. Native addons are compiled for your specific environment when you npm install.
If you're moving between environments, you can npm rebuild to rebuild those binaries for the new environment. Or the more lengthy way, remove the node_modules folder and npm install again.
Fatal error: spawn ENOENT means a process node.js is trying to spawn does not exist. A common case when trying to spawn a binary compiled for another environment, the binary it is expecting does not exist.

Resources