npm err! code 1 when performing npm install - node.js

I have looked at the other posts concerning other people who had this or similar problems and those fixes don't seem to be working for me. When I run "npm install" I constantly get the line "npm ERR! code 1"
This is preventing me form getting to test my code as I can't install my node modules.
Here is part the output:
npm ERR! code 1
npm ERR! path /Users/myname/Documents/blip/blip-api-billbot/node_modules/mongodb-client-encryption
npm ERR! command failed
npm ERR! command sh -c prebuild-install --tag-prefix node-v || node-gyp rebuild
The package.json file:
{
"name": "blip-api-billbot",
"version": "1.0.0",
"description": "Blip's billbot architecture for creating links to biller accounts.",
"main": "chrome-script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"linuxRebuild": "docker run --rm -v '$PWD':/var/task lambci/lambda:build-nodejs12.x npm rebuild"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#babel/runtime": "^7.12.13",
"aws-sdk": "^2.824.0",
"axios": "^0.21.0",
"axios-cookiejar-support": "^1.0.1",
"base-64": "^1.0.0",
"bindings": "^1.5.0",
"cheerio": "^1.0.0-rc.5",
"chrome-aws-lambda": "^5.5.0",
"dotenv": "^8.2.0",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"lambda-packager": "^0.2.1",
"mongodb": "^3.6.3",
"mongodb-client-encryption": "^1.1.0",
"node-downloader-helper": "^1.0.15",
"node-fetch": "^2.6.1",
"puppeteer": "^2.1.1",
"puppeteer-extra": "^3.1.15",
"puppeteer-extra-plugin-adblocker": "^2.11.9",
"puppeteer-extra-plugin-repl": "^2.2.8",
"puppeteer-extra-plugin-stealth": "^2.6.5",
"qs": "^6.9.4",
"rimraf": "^3.0.2",
"serverless-docker-artifacts": "^0.1.1",
"serverless-dotenv-plugin": "^3.1.0",
"serverless-offline": "^5.12.1",
"serverless-plugin-scripts": "^1.0.2",
"tough-cookie": "^4.0.0",
"uuid": "^8.3.2",
"uuid-mongodb": "^2.4.1"
}
}

Related

npm run: command not found

When I try to run npm run dev or npm run build I get the following error:
npm run dev
> dev
> next
/usr/bin/bash: D:Tempdev-1656515078305.sh: command not found
This is my current package.json:
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"type-check": "tsc"
},
"dependencies": {
"bootstrap": "^5.1.3",
"marked": "^4.0.17",
"next": "latest",
"nodemailer": "^6.7.5",
"react": "^18.1.0",
"react-bootstrap": "^2.4.0",
"react-dom": "^18.1.0",
"react-icons": "^4.4.0"
},
"devDependencies": {
"#fullhuman/postcss-purgecss": "^4.1.3",
"#types/node": "^17.0.35",
"#types/react": "^18.0.9",
"#types/react-dom": "^18.0.4",
"#typescript-eslint/eslint-plugin": "^5.30.0",
"#typescript-eslint/parser": "^5.30.0",
"eslint": "^8.18.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.3",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss-preset-env": "^7.6.0",
"sass": "^1.53.0",
"tailwindcss": "^3.0.24",
"typescript": "4.6"
}
}
I have absolutely no idea why this error occurs.
NodeJS and NPM are installed:
node -v
v16.14.2
npm -v
8.13.1
I've encountered this issue when calling one run-script from another. Using npm-run-all and run-s to launch commands fixed my issues in some scenarios. I suspect that npm is making some assumptions about the shell and path separator based on the 'platform' or not properly introspecting the running shell.

Can't resolve dependency, refering to root project - next#"^9.5.6-canary.13, next-routes#"^1.4.2"

I am trying for hours to resolve this issue, running from one error to the next one…
Trying everything from --legacy-peer-deps, --force npm audit fix, at this point I am not even able to install my packages without running into errors, and I don't understand what that error is saying:
npm ERR! Found: next#9.5.6-canary.18
npm ERR! node_modules/next
npm ERR! next#"^9.5.6-canary.13" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next#">=2" from next-routes#1.4.2
npm ERR! node_modules/next-routes
npm ERR! next-routes#"^1.4.2" from the root project
My package.json:
{
"name": "project-name",
"version": "0.1.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "next dev",
"dev": "node server.js",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#apollo/client": "^3.3.19",
"apollo-boost": "^0.4.9",
"babel-loader": "^8.2.2",
"babel-register": "^6.26.0",
"dotenv": "^8.2.0",
"framer-motion": "^4.0.0",
"fs": "0.0.1-security",
"graphql": "^15.5.0",
"https": "^1.0.0",
"ignore-loader": "^0.1.2",
"lazysizes": "^5.3.2",
"next": "^9.5.6-canary.13",
"next-routes": "^1.4.2",
"node-webvtt": "^1.9.3",
"path": "^0.12.7",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"sass": "^1.32.6",
"storyblok-js-client": "^4.0.5",
"url": "^0.11.0"
},
"devDependencies": {
"#babel/register": "^7.12.13",
"#types/node": "^14.14.37",
"#types/react": "^17.0.3",
"dotenv-webpack": "^6.0.0",
"typescript": "^4.2.4"
}
}
I am guessing some of the longer list of packages are not playing along with each other, but how can I investigate this further? The error is not very helpful. Also the similar combinations of packages and version seem to work fine in other projects …
The error originally complained about graphql packages I am using, after updating some versions it is now complaining about the next and next-routes packages …
Any ideas?

node start error in Windows

Windows MEVN stack project
i have npm start terminal output:
$ npm start
> nodejs-starter#1.0.0 start C:\final-dip\diplom-master
> SECRET=diplom nodemon index.js
"SECRET" is not internal or external
command, executable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodejs-starter#1.0.0 start: `SECRET=diplom nodemon index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-starter#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2018-05-04T10_33_19_073Z-debug.log
code in package.json:
{
"name": "nodejs-starter",
"version": "1.0.0",
"description": "A boilerplate for NodeJS web servers",
"main": "index.js",
"scripts": {
"start": "SECRET=diplom nodemon index.js",
"init": "node ./controllers/init",
"debug": "cross-env PORT=3333 SECRET=GREEN_BUS nodemon --inspect index.js"
},
"keywords": [],
"author": "Almat Ybray",
"license": "MIT",
"devDependencies": {
"eslint": "^4.14.0",
"nodemon": "^1.14.7"
},
"dependencies": {
"async": "^2.6.0",
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"express": "^4.16.2",
"express-jwt": "^5.3.1",
"express-validator": "^5.0.3",
"helmet": "^3.9.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^5.0.0-rc1",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"socket.io": "^2.0.4"
}
}
You're missing cross-env for your start script. Change your package.json to:
{
"scripts": {
"start": "cross-env SECRET=diplom nodemon index.js"
}
}
It's already being used in the debug script.
NOTE It's also not part of dependencies so it has to be added via npm i cross-env --save.

node container keeps failing to install dependencies websocket.io

I'm trying to build my test container using drone ci but it always fails
when trying to install websocket.io
with the error, I added npm install -g node-gyp as adviced but the problem still exists
npm info lifecycle compression#1.6.2~install: compression#1.6.2
npm info lifecycle express#4.14.0~install: express#4.14.0
npm info lifecycle nodeadmin#0.1.2~install: nodeadmin#0.1.2
npm info lifecycle vizion#0.2.13~install: vizion#0.2.13
npm info lifecycle websocket#1.0.24~install: websocket#1.0.24\
websocket#1.0.24 install /drone/src/bitbucket.org/xxxx/xxxxxxx/node_modules/websocket
(node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory '/drone/src/bitbucket.org/xxxxxx/xxxx/node_modules/websocket/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
this is my package.json
{
"name": "calm-cell",
"version": "1.0.0",
"description": "th backend app",
"scripts": {
"start": "node server.js",
"setup":"./node_modules/.bin/mocha 'test/setupDb.js' --reporter spec --timeout 3000",
"test": "./node_modules/.bin/mocha 'test/appTest.js' --reporter spec --timeout 3000",
"test:client": "karma start --single-run",
"test:server": "mocha --recursive"
},
"dependencies": {
"async": "^1.5.2",
"bcrypt-nodejs": "^0.0.3",
"bluebird": "^3.4.1",
"body-parser": "^1.15.1",
"bookshelf": "^0.9.2",
"compression": "^1.6.2",
"cookie-parser": "^1.4.1",
"dotenv": "^2.0.0",
"express": "^4.13.4",
"express-validator": "^2.20.4",
"json-2-csv": "^2.0.22",
"json2csv": "^3.6.2",
"jsonwebtoken": "^5.7.0",
"jwt-decode": "^2.1.0",
"jwt-then": "^0.4.1",
"knex": "^0.10.0",
"loadtest": "^1.4.4",
"mkdirp": "^0.5.1",
"moment": "^2.12.0",
"morgan": "^1.7.0",
"mysql": "^2.10.2",
"node-uuid": "^1.4.7",
"nodeadmin": "^0.1.2",
"nodemailer": "^2.5.0",
"opbeat": "^3.16.0",
"pdf-invoice": "^1.0.2",
"pm2": "^1.1.3",
"pmx": "^0.6.3",
"request": "^2.69.0"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-http": "^3.0.0",
"karma": "^0.13.22",
"karma-chai": "^0.1.0",
"karma-coverage": "^0.5.5",
"karma-mocha": "^1.0.1",
"mocha": "^2.5.3",
"nodeman": "^1.1.2",
"mocha-junit-reporter": "^1.12.1",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"supertest": "^1.2.0"
},
"engines": {
"node": "6.1.0"
}
}
and this is drone yml file
build:
image: node:boron
commands:
- npm install -g node-gyp
- npm update # Update your personal npm local repository again.
- npm install
- npm run setup
- npm run test
environment:
- EXAM_SERVER_URL=http://S8.dummy.com
- FETCH_SERVER_FETCH_API='/getSomething?something='
- TOKEN_SECRET=superSecretFakeToken
- DB_HOST=localhost
- DB_USER=root
- DB_PASSWORD=thisIsFakePassword
- DB_NAME=thisIsFakeDB
compose:
database:
image: mysql:5.6
environment:
- MYSQL_ROOT_PASSWORD=thisIsFakePassword
- MYSQL_DATABASE=thisIsFakeDB

How to resolve gulp dependencies while creating a NPM package

I have a nodeJs application(demo) which using commander package to take command line argument and using gulp for
build
docs
test
coverage
This functionality is working fine but Now I need to move this application as a NPM Package.
Changes are done according to according NPM Package but when I install this as NPM package npm install ../demo/ from local location.
It asks for following gulp dependencies: -
Cannot find module gulp
Cannot find module gulp-load-plugins
Cannot find module del
Cannot find module gulp-plumber
Cannot find module gulp-eslint
Cannot find module babel-eslint
Cannot find module gulp-debug
Cannot find module gulp-sourcemaps
Cannot find module gulp-babel
Every time I go back to the npm package(which i created) directory and run the command which occurs as an error like npm install gulp --save-dev and npm install del --save-dev and so on.
I also defined these dependencies in package.json but it is still throwing errors.
Is there any way to resolve this issue.
package.json
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1"
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}
I put all the things in dependencies. I tried that way but having same problem.
npm install ../demo/
npm WARN package.json demo_project#1.0.0 No description
npm WARN package.json demo_project#1.0.0 No repository field.
npm WARN package.json demo_project#1.0.0 No README data
> demo#0.0.1 prepublish /work/demo
> gulp build
[16:53:33] Local gulp not found in ~/work/demo
[16:53:33] Try running: npm install gulp
Although the documentation doesn't mention it, npm install folder only installs dependencies and not devDependencies. This may be a little bit confusing as running npm install inside the package folder installs both dependenciesand devDependencies.
So try to install gulpand all the rest as npm install --save gulp (not
--save-dev)
UPDATE: after adding package.json:
everything under devDependencies in your package.json should be under dependencies:
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1",
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}

Resources