npm install - ERR! addLocal Could not install on Windows 10 - node.js

I'm trying to install a new nodeJS project.
I set node and npm as environment variable
When I run command npm install, I got errors as below:
What is my wrong?
Update details of package.json
{
"name": "Project for myself",
"version": "2.0.0",
"private": true,
"scripts": {
"start": "node_modules/react-native/packager/packager.sh",
"test": "jest"
},
"dependencies": {
"firebase": "^3.6.4",
"lodash": "^4.17.2",
"moment": "^2.17.1",
"react": "15.4.2",
"react-addons-shallow-compare": "^15.3.2",
"react-immutable-component": "^0.0.1",
"react-native": "0.42.0-rc.3",
"react-native-admob": "git://github.com/minhcasi/react-native-admob.git",
"react-native-animatable": "0.*",
"react-native-drawer": "2.*",
"react-native-dropdownalert": "^2.3.0",
"react-native-fbsdk": "0.*",
"react-native-fence-html": "^1.0.6",
"react-native-global-props": "^1.1.1",
"react-native-invertible-scroll-view": "^1.0.0",
"react-native-linear-gradient": "2.*",
"react-native-localization": "0.*",
"react-native-modalbox": "1.*",
"react-native-onesignal": "^3.0.3",
"react-native-parallax-scroll-view": "0.*",
"react-native-router-flux": "3.*",
"react-native-scrollable-tab-view": "0.*",
"react-native-smart-splash-screen": "^2.2.1",
"react-native-snap-carousel": "^1.4.0",
"react-native-spinkit": "1.*",
"react-native-swiper": "1.*",
"react-native-timeago": "0.*",
"react-native-vector-icons": "4.*",
"react-timer-mixin": "^0.13.3",
"react-tween-state": "^0.1.5",
"readable-stream": "^2.2.2",
"safe-html": "^1.0.0",
"sanitize-html": "^1.13.0",
"urijs": "^1.18.4",
"url": "^0.11.0",
"util": "^0.10.3",
"wpapi": "^1.0.1"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.1.0",
"react-test-renderer": "15.4.2"
},
"jest": {
"preset": "react-native"
}
}
The installing worked with this package.json content:
{
"name": "Project for myself",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0-alpha.6",
"react-native": "0.43.4"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "16.0.0-alpha.6"
},
"jest": {
"preset": "react-native"
}
}

Issue is with the version of your application, to fix edit your package.json files version parameter to valid format
"version": "2.0.0"
For more information on node.js versioning refer the following documentation.
UPDATE
Try following and try again,
npm cache clear -f

Related

502 Bad Gateway (nginx/1.14.0 (Ubuntu))

Hi i have a server with multiple subdomain a weird issue started when all domains returned with 502 bad gateway i entered one subdomain and i run npm run dev and it worked but all the remain subdomains still 502, when i go to other subdomain and run npm start the subdomain work while all the other return 502 what should i do.
here's my package for web (on a subdomain)
{
"name": "mmy-route-web",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#fortawesome/react-fontawesome": "^0.1.16",
"#glidejs/glide": "^3.4.0",
"#mailchimp/mailchimp_marketing": "^3.0.43",
"#popperjs/core": "^2.9.2",
"#stripe/stripe-js": "^1.13.2",
"bootstrap": "^5.0.0-beta3",
"cloudinary-build-url": "^0.2.1",
"cloudinary-react": "^1.7.0",
"cookie": "^0.4.1",
"html-react-parser": "^1.2.6",
"lodash": "^4.17.21",
"next": "10.0.9",
"next-iron-session": "^4.1.12",
"nookies": "^2.5.2",
"npm": "^8.1.0",
"parse": "^3.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-use-tawk": "^1.0.0",
"sass": "^1.32.8",
"stripe": "^8.145.0",
"styled-components": "^5.2.1",
"swr": "^0.5.5"
},
"browser": {
"child_process": false
}
}
and for my backend (on other subdomain):
{
"name": "parse-server-example",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/"
},
"license": "MIT",
"dependencies": {
"#parse/fs-files-adapter": "^1.2.0",
"concurrently": "^7.0.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"jimp": "^0.16.1",
"kerberos": "0.0.24",
"nodemailer": "^6.4.17",
"parse": "~1.8.0",
"parse-dashboard": "^2.1.0",
"parse-server": "*",
"parse-server-cloudinary-adapter": "^1.4.0",
"parse-server-dedicated-email-adapter": "^3.0.6",
"parse-server-email-template-adapter": "^1.0.2",
"parse-server-generic-email-adapter": "0.0.4",
"parse-smtp-template": "^2.2.0",
"slugify": "^1.4.6"
},
"scripts": {
"start": "node index.js",
"dev": "concurrently \"cd server && npm run start\" \"npm run start\""
},
"engines": {
"node": ">=4.3"
}
}

SyntaxError: Cannot use import statement outside a module using jest

I'm trying to start tests using Jest, but I'm not able to use "import", so how can I use import in Jest?
plus.js
function addTwo(num) {
return num + 2;
}
export { addTwo };
test.js
import { addTwo } from './plus';
test('adds 1 + 2 to equal 3', () => {
expect(addTwo(4)).toBe(6);
});
Error:
My package.json:
{
"name": "...",
"version": "1.0.0",
"title": "...",
"homepage": "http://...",
"devDependencies": {
"#babel/core": "7.12.3",
"babel-loader": "8.1.0",
"btoa": "1.2.1",
"chalk": "3.0.0",
"circular-dependency-plugin": "5.2.0",
"css-loader": "5.0.0",
"dp-grunt-contrib-copy": "0.4.4",
"eslint": "5.16.0",
"eslint-loader": "4.0.2",
"file-loader": "6.2.0",
"filemanager-plugin": "2.5.2",
"generate-json-webpack-plugin": "2.0.0",
"grunt": "1.1.0",
"grunt-contrib-clean": "0.7.0",
"grunt-contrib-compress": "1.6.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "1.0.2",
"grunt-cssjoin": "0.3.0",
"grunt-eslint": "21.1.0",
"grunt-exec": "3.0.0",
"grunt-jsmin-sourcemap": "1.10.0",
"grunt-terser": "0.1.0",
"grunt-writefile": "0.1.4",
"html-loader": "1.3.2",
"jest": "^26.6.3",
"jwt-decode": "3.0.0",
"mini-css-extract-plugin": "1.2.1",
"npm-run-all": "4.1.5",
"prettier": "2.1.2",
"prettier-webpack-plugin": "1.2.0",
"resize-observer-polyfill": "1.5.1",
"sass": "1.25.0",
"sass-loader": "10.0.4",
"sha1": "1.1.1",
"ssh2": "0.8.9",
"style-loader": "2.0.0",
"vue-virtual-scroller": "1.0.10",
"webpack": "5.3.1",
"webpack-cli": "3.3.12",
"xmlhttprequest": "1.8.0"
},
"dependencies": {
"inputmask": "5.0.0",
"jquery": "2.1.3",
"requirejs": "2.3.6",
"vue": "2.6.10",
"vue-i18n": "8.15.3",
"vuedraggable": "2.23.2"
},
"scripts": {
"build": "npm run dev && bash ./build.sh",
"lint": "npx eslint --fix --quiet .",
"prettier": "npx prettier --config ./.prettierrc.json --write ./**/*.{scss,js}",
"prod": "node node/compiler.js prod",
"dev": "node node/compiler.js dev",
"backup-log": "node node/logger.js",
"test": "jest"
}
}
The solution was install #babel/preset-env:
npm install --save-dev #babel/preset-env
Create a file babel.config.js
module.exports = {
presets: [['#babel/preset-env', {targets: {node: 'current'}}]],
};

How to get node packages up-to-date?

I've used a truffle react box to get an app working. npm install gives me lots of deprecation warnings, and alos that some packages need others that aren't installed. Is there a good way, or a place online, that can get my package.json file up to date? Since I'm really new to react, I think having missing packages is sure to cause a lot of lost time. Thank you.
package.json
{
"name": "someApp",
"version": "0.1.0",
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "some repo..."
},
"main": "src/index.js",
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom --watch"
},
"dependencies": {
"dotenv": "^2.0.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router-dom": "^4.3.1"
},
"devDependencies": {
"autoprefixer": "6.5.1",
"babel-core": "6.17.0",
"babel-eslint": "7.1.1",
"babel-jest": "17.0.2",
"babel-loader": "6.2.7",
"babel-preset-react-app": "^2.0.1",
"case-sensitive-paths-webpack-plugin": "1.1.4",
"chalk": "1.1.3",
"connect-history-api-fallback": "1.3.0",
"cross-spawn": "4.0.2",
"css-loader": "0.26.0",
"debug": "^3.1.0",
"detect-port": "1.0.1",
"eslint": "3.8.1",
"eslint-config-react-app": "^0.5.0",
"eslint-loader": "1.6.0",
"eslint-plugin-flowtype": "2.21.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.4.1",
"extract-text-webpack-plugin": "1.0.1",
"file-loader": "0.9.0",
"filesize": "3.3.0",
"fs-extra": "0.30.0",
"growl": "^1.10.2",
"gzip-size": "3.0.0",
"html-webpack-plugin": "2.24.0",
"http-proxy-middleware": "0.17.2",
"jest": "19.0.1",
"json-loader": "0.5.4",
"minimatch": "^3.0.2",
"object-assign": "4.1.0",
"openzeppelin-solidity": "1.11.0",
"path-exists": "2.1.0",
"postcss-loader": "1.0.0",
"promise": "7.1.1",
"react-dev-utils": "^0.4.2",
"recursive-readdir": "2.1.0",
"stmux": "^1.5.5",
"strip-ansi": "3.0.1",
"style-loader": "0.13.1",
"truffle": "^4.1.13",
"truffle-contract": "^1.1.8",
"truffle-hdwallet-provider": "0.0.6",
"truffle-solidity-loader": "0.0.8",
"url-loader": "^1.0.1",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2",
"webpack-manifest-plugin": "^1.1.0",
"whatwg-fetch": "^1.0.0"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js?(x)",
"<rootDir>/coverage/**/?(*.)(spec|test).js?(x)"
],
"testEnvironment": "node",
"testURL": "http://127.0.0.1:7200",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx"
]
},
"babel": {
"presets": [
"react-app"
]
},
"eslintConfig": {
"extends": "react-app"
}
}
A really cool package i've used is npm-check
It provides a nice interface to tell you what packages are outdated.
interface image
to install the package, run in your terminal: npm install -g npm-check
To check packages, run: npm-check in the directory that contains the package.json you are checking.

Managing React Native 0.44.0 using yarn; dependency issues causing packager to crash

As stated I am using yarn as a package manager, and recently upgraded my application to React-Native 0.44.0. My package.json is as follows:
{
"name": "Project",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"postinstall": "node_modules/.bin/rn-nodeify --install crypto --hack"
},
"dependencies": {
"assert": "^1.4.1",
"asyncstorage-down": "^3.1.1",
"braintree": "^1.46.0",
"browserify-zlib": "^0.1.4",
"buffer": "^3.6.0",
"console-browserify": "^1.1.0",
"constants-browserify": "0.0.1",
"create-hmac": "^1.1.4",
"dns.js": "^1.0.1",
"domain-browser": "^1.1.7",
"events": "^1.1.1",
"firebase": "^3.6.3",
"global": "^4.3.2",
"https-browserify": "0.0.1",
"jest-haste-map": "^18.1.0",
"jwt-simple": "^0.5.1",
"moment": "^2.17.1",
"os-browserify": "^0.1.2",
"path-browserify": "0.0.0",
"process": "^0.11.9",
"querystring-es3": "^0.2.1",
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-cli": "^2.0.1",
"react-native-crypto": "^2.0.1",
"react-native-facebook-login": "^1.4.0",
"react-native-google-places-autocomplete": "^1.2.6",
"react-native-http": "github:tradle/react-native-http#834492d",
"react-native-level-fs": "^2.0.1",
"react-native-linear-gradient": "1.5.15",
"react-native-looped-carousel": "^0.1.4",
"react-native-maps": "0.12.4",
"react-native-material-kit": "^0.4.1",
"react-native-randombytes": "^2.2.0",
"react-native-router-flux": "3.37.0",
"react-native-svg": ">=5.1.8",
"react-native-svg-uri": "0.0.3",
"react-native-tcp": "^2.0.4",
"react-native-textinput-effects": "^0.2.0",
"react-native-twitter-signin": "github:rakannimer/react-native-twitter-signin",
"react-native-udp": "^1.2.9",
"react-native-vector-icons": "^3.0.0",
"readable-stream": "^1.0.33",
"rn-nodeify": "^6.0.1",
"stream-browserify": "^1.0.0",
"timers-browserify": "^1.4.2",
"tty-browserify": "0.0.0",
"url": "^0.10.3",
"vm-browserify": "0.0.4"
},
"jest": {
"preset": "react-native"
},
"devDependencies": {
"babel-jest": "17.0.2",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.3",
"react-test-renderer": "15.4.1"
},
"react-native": {
"crypto": "react-native-crypto",
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "os-browserify",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify"
},
"browser": {
"crypto": "react-native-crypto",
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "os-browserify",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify"
}
}
Running react-native run-android succeeds in building the project, but then the packager crashes with te following error:
Bundling `index.android.js` 44.9% (327/488), failed.
Error: ENOENT: no such file or directory, open '/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native-svg/node_modules/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js'
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at Module._readSourceCode (/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native/packager/src/node-haste/Module.js:200:29)
at Module._getCacheProps (/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native/packager/src/node-haste/Module.js:420:29)
at Module._readFromTransformCache (/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native/packager/src/node-haste/Module.js:376:29)
at Module.readCached (/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native/packager/src/node-haste/Module.js:363:25)
at Promise.resolve.then (/Users/chrisdock/Desktop/Jdoe/jdoe-redux/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:167:29)
I'm not sure why the packager is looking for nested dependencies instead of in node_modules/react-native, or why yarn doesn't just install the nested dependencies if that's what it needs to do.

reactJs Jest:`jsdom 4.x onward only works on io.js, not Node.jsT:

package.json:
{
"name": "flux-pricing",
"version": "0.0.1",
"description": "Pricing component with flux",
"main": "js/app.js",
"dependencies": {
"flux": "^2.0.0",
"jest-cli": "^0.5.0",
"jsdom": ">= 0.1.23 < 4.0.0",
"react": "^0.12.0",
"underscore": "^1.7.0"
},
"devDependencies": {
"browserify": "~6.2.0",
"envify": "~3.0.0",
"react": "^0.12.0",
"reactify": "^0.15",
"watchify": "~2.1.0",
"gulp": "~3.8.9",
"gulp-browserify": "~0.5.0",
"gulp-concat": "~2.4.1",
"node-jsx": "~0.2.0",
"express": "~4.0.0"
},
"scripts": {
"start": "watchify -o js/bundle.js -v -d .",
"build": "browserify . | uglifyjs -cm > js/bundle.min.js",
"test": "jest"
},
"jest": {
"rootDir": "./js"
},
"browserify": {
"transform": [
"reactify",
"envify"
]
}
}
after npm install when i try to do npm test
s\jsdom\lib\jsdom.js:3
`jsdom 4.x onward only works on io.js, not Node.jsT: https://github.com/tmpvar
^
Unexpected token ILLEGAL
how to resolve this issue?
I had the same problem. The solution is to switch to use Jest 0.4 instead.
Here's the issue from github.
https://github.com/facebook/jest/issues/469#issuecomment-133105627
I actually had to downgrade to Jest 0.3 and node 10.x to get the Jest React example working. Here's the reference
https://github.com/facebook/jest/issues/427

Resources