I'm developing an application in Vue, also using the x-ray-scraper library, but when I try to run npm run serve in the console to view the application locally I get the following error:
This dependency was not found:
* _http_common in ./node_modules/http-outgoing/index.js
To install it, you can run: npm install --save _http_common
Then I tried to run the command npm install --save _http_common and again I get an error:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for undefined#_http_common.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
Without the x-ray-scraper library, everything starts up fine, but if I include it in my project, errors appear.
Perhaps the error is related to the version, but I don't understand how to fix it.
My package.json looks like:
{
"name": "pc-components",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.21.0",
"cheerio": "^1.0.0-rc.3",
"core-js": "^3.6.5",
"dns": "^0.2.2",
"phantom": "^6.3.0",
"selenium-webdriver": "^4.0.0-alpha.8",
"vue": "^2.6.11",
"webpage": "^0.3.0",
"x-ray-scraper": "^3.0.6"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"vue-template-compiler": "^2.6.11"
}
}
Thanks for any help.
The issue has nothing to do with the import statement, nor are there any issue with the dependencies you have installed.
This is my test:
npm init into any directory you want
npm install x-ray-scraper
Then:
const x = require("x-ray-scraper");
x('google.com', 'title')
.then((title) => {
console.log(title); // Google
});
// logs Google
You need a simple backend, even a couple of lines long, in order to initiate the service and use the package.
You can use whatever you like in the front-end, Vue, React, etc.
You do not need any extra dependencies at all from what you already have.
Please read the docs to see use cases
Related
I have a project that already was deployed on Vercel. Since last week Im working on improve the layout with the goal of finish a MVP of this project. So, I changed my usage of auth0, using the package to nextjs #auth0/nextjs-auth0. I ran
npm install #auth0/nextjs-auth0
and I have on my package.json
{
"name": "MAmanager",
"version": "1.0.0",
"engines": {
"node": "14.x",
"npm": "6.x"
},
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"start": "next start",
"build": "next build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#auth0/nextjs-auth0": "github:auth0/nextjs-auth0",
"dayjs": "^1.9.5",
"formik": "^2.1.5",
"next": "^10.2.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"swr": "^0.5.6",
"yup": "^0.29.3"
},
"devDependencies": {
"autoprefixer": "^10.2.5",
"postcss": "^8.3.0",
"tailwindcss": "^2.1.2"
}
}
The usages on my pages are
import { UserProvider } from '#auth0/nextjs-auth0'
import { useUser } from '#auth0/nextjs-auth0'
import { withPageAuthRequired } from '#auth0/nextjs-auth0'
And when I deploy my branch on Vercel I get this error
08:57:49.989 Failed to compile.
08:57:49.990 ModuleNotFoundError: Module not found: Error: Can't resolve '#auth0/nextjs-auth0' in '/vercel/path0/pages'
08:57:49.990 > Build error occurred
08:57:49.991 Error: > Build failed because of webpack errors
08:57:49.991 at /vercel/path0/node_modules/next/dist/build/index.js:17:924
08:57:49.991 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
08:57:50.020 error Command failed with exit code 1.
I have seen errors like that caused by casing discrepancies but I don't understanding what is happening here. I appreciate any help.
After see other examples I just edited manually the package.json.
After run npm install #auth0/nextjs-auth0 the package was automatically added "#auth0/nextjs-auth0": "github:auth0/nextjs-auth0",.
I just edit to
"#auth0/nextjs-auth0": "^1.3.1"
and worked on deployment.
Note: The way the package was installed worked on dev in localhost but broke only on the deployment.
try making a custom build script for your deployment as a temporary workaround:
npm install && npm i #auth0/nextjs-auth0#1.3.1 && npm run build
This can be added under the deployment settings tab using a custom build command for production. Running the specific targeted package version install after npm i should override the problematic version being installed in prod
My Node.js app run well before. I put this Node.js app aside for several months and return back to continue to develop it on a new machine. Error happens!!!
Error information is as follows:
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/graceful-ncp/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
And my package.json is:
{
"name": "meminsight",
"version": "0.0.1",
"description": "JavaScript memory analyses",
"repository": {
"type": "git",
"url": "https://github.com/Samsung/meminsight.git"
},
"dependencies": {
"acorn": "3.1.0",
"argparse": "0.1.15",
"aspect-js": "^1.0.3",
"callsites": "^2.0.0",
"chai": "^4.1.2",
"codemirror": "5.1.0",
"cover": "0.2.9",
"datatables": "^1.10.18",
"ejs": "1.0.0",
"escope": "1.0.1",
"esotope": "1.4.5",
"estraverse": "4.0.0",
"execSync": "1.0.2",
"expect.js": "^0.3.1",
"express": "3.4.8",
"fast-stats": "0.0.2",
"finalhandler": "0.0.3",
"graceful-ncp": "2.0.0",
"grunt": "0.4.5",
"jquery": "2.1.3",
"jsonparse": "0.0.6",
"line-by-line": "0.1.3",
"line-reader": "^0.4.0",
"log4js": "^2.3.11",
"mkdirp": "0.5.0",
"mocha": "^1.20.1",
"multi-key-cache": "^1.0.2",
"parse5": "2.1.5",
"q": "1.2.0",
"rewriting-proxy": "0.5.1",
"rimraf": "2.2.8",
"serve-static": "^1.14.1",
"sloc": "^0.2.1",
"temp": "0.8.1",
"websocket": "^1.0.30",
"wrench": "1.5.8"
},
"scripts": {
"test": "(cat test/testSuite.txt | sed 's/^/test\\//' | xargs ./node_modules/.bin/mocha --reporter spec --harmony) && cd lifetime-analysis && ./gradlew cleanTest test && cd ..",
"build": "grunt typescript"
},
"devDependencies": {
"grunt-cli": "0.1.13",
"grunt-exec": "^0.4.6",
"grunt-simple-mocha": "0.4.0",
"grunt-typescript": "^0.8.0",
"jasmine": "^2.8.0"
},
"license": "Apache-2.0"
}
It seems that something wrong in the the dependent module natives. However, according to the package.json file, the app do not rely on natives module. In addition, there is not variable named primordials in index.js file of natives module.
Additonal information:
Version of Node.js: 12.10.0;
Version of npm: 6.11.3;
I also encounter an error that gyp ERR! build error when I npm install the app. I use the command npm audit fix to fix it. Is this related to my issue?
Could anyone help me about this issue? I am new to Node.js and have less experience to debug out of myself codes. Thanks a lot.
The natives npm package is deprecated: https://www.npmjs.com/package/natives.
If you go its page, they warn about that the package may break in future node versions -- they seriously suggest against using the package in the first place, too. I guess either a different OS or node version is the culprit here. The fact that you don't have natives listed in your package.json as dependency, means that at least one of your dependencies is using natives -or a dependency of one of your dependencies and so on...-.
One way you can check which dependencies are using natives is to run:
$ npm ls natives
I installed your dependencies in a project in my local machine -MacOS 10- and run it, and it appears that graceful-fs is using natives. graceful-fs is a dependency of graceful-ncp, which is listed in your package.json.
When I did $npm install I got several warnings, one of them about upgrading graceful-fs to version 4 to avoid future errors when upgrading node version.
The graceful-ncp package is currently on version 3.0.0, so I upgraded the version in package.json to 3.0.0. Then $ rm -rf node_modules && npm i;
After that, $ npm ls natives yields empty, which means upgrading graceful-ncp version should fix your problem - of course, you may need to add changes to your code to avoid breaking changes of graceful-ncp.
I am trying to install libraries from npmjs.com and save them as dependencies on my existing react native app. Installation instruction say to write npm install twit in terminal. So, in VScode, with the application open, I enter this in the terminal. After installation, the terminal will say something like:
+ react-native-twitter#0.2.1
added 3 packages, removed 945 packages and updated 1 package in 14.238s
Now I cannot run the application on the android simulator etc.
Can someone explain what I may be doing wrong and what kinds of libraries I can/cannot add? For example, must the library be built specifically for react/react native?
Thanks
error when running simulator:
react-native run-android
Command run-android unrecognized. Make sure that you have run npm
install and that you are inside a react-native project.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AwesomeProject#0.0.1 android: react-native run-android
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AwesomeProject#0.0.1 android 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!
/Users/admin/.npm/_logs/2019-01-03T03_13_17_686Z-debug.logPackage.json:
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"ios": "react-native run-ios",
"android": "react-native run-android"
},
"dependencies": {
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-twitter": "^0.2.1"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.5",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
Can you tell the error when you run app in simulator?
Add your package.json file. It may be more helpful to find the answer.
You can recovery it using following step.
Go to package.json file and under the dependency delete react-native-twitter#0.2.1
Then delete your node file.
type cmd npm install
Then react-native run-android
Now you can run your app in previous version.
I have setup jest and jest-junit as the reporter and followed the simple instructions given by jest-junit.
This includes npm install jest --save-dev and npm install jest-junit --save-dev
My package.json looks like this (excerpt):
"devDependencies": {
"jest": "^22.4.4",
"jest-junit": "^4.0.0",
},
"scripts": {
"test": "jest --ci --testResultsProcessor='jest-junit'"
},
"jest": {
"verbose": true,
"testResultsProcessor": "jest-junit"
},
"jest-junit": {
"suiteName": "Test Suite",
"output": "./junit.xml"
}
When running npm run test on my machine (OSX), it works well. When running it as part of the CI build process or on another Windows machine, I am getting the following error:
Module 'jest-junit' in the testResultsProcessor option was not found.
Maybe you just need to install the missing module to the other machine:
npm install jest-junit
Found the solution and it was the removal of inverted commas.
"test": "jest --ci --testResultsProcessor='jest-junit'"
should become
"test": "jest --ci --testResultsProcessor=jest-junit"
Eslint works with setup below but causes few errors I do not understand.
As you can see when I run meteor npm run lint npm throws error below. It completes the lint and then says it failed to complete?
--UPDATE-- I fixed this issue by adding exit 0 attribute to gracefully exit the eslit process. If you run into the same issue look at my package.json line "lint": "eslint .;exit 0", to fix this. Leaving this for reference
Problem is that I am not sure how to make eslint ignore imports from the meteor. I have tried with eslint-plugin-meteor and turning on import resolver meteor, but that does not seem to work.
--UPDATE-- I silenced errors in .eslintrc file in below question, until issue described below is fixed [https://github.com/clayne11/eslint-import-resolver-meteor/issues/11] Leaving this for reference
/Users/kimmo/Documents/carecity/server/main.js
1:1 error 'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it import/no-extraneous-dependencies
1:24 error Unable to resolve path to module 'meteor/meteor' import/no-unresolved
✖ 2 problems (2 errors, 0 warnings)
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/kimmo/.meteor/packages/meteor-tool/.1.4.1_1.1ugzqvs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/node" "/Users/kimmo/.meteor/packages/meteor-tool/.1.4.1_1.1ugzqvs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/npm" "run" "lint"
npm ERR! node v4.5.0
npm ERR! npm v3.10.6
npm ERR! code ELIFECYCLE
npm ERR! carecity# lint: eslint .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the carecity# lint script 'eslint .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the carecity package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs carecity
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls carecity
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/kimmo/Documents/carecity/npm-debug.log
My package.json file below >
{
"name": "carecity",
"private": true,
"scripts": {
"start": "meteor run",
"lint": "eslint .;exit 0",
"pretest": "npm run lint --silent"
},
"eslintConfig": {
"parser": "babel-eslint",
"parserOptions": {
"allowImportExportEverywhere": true
},
"plugins": [
"meteor"
],
"extends": [
"airbnb",
"plugin:meteor/recommended"
],
"settings": {
"import/resolver": "meteor"
},
"rules": {}
},
"dependencies": {
"algoliasearch": "^3.18.1",
"instantsearch.js": "^1.8.5",
"material-icons": "^0.1.0",
"material-ui": "^0.15.4",
"meteor-node-stubs": "~0.2.0",
"react": "^15.3.1",
"react-addons-pure-render-mixin": "^15.3.1",
"react-dom": "^15.3.1",
"react-router": "^2.8.0",
"react-tap-event-plugin": "^1.0.0",
"roboto-fontface": "^0.6.0"
},
"devDependencies": {
"babel-eslint": "^6.1.2",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-import-resolver-meteor": "^0.3.3",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-jsx-a11y": "^2.2.1",
"eslint-plugin-meteor": "^4.0.0",
"eslint-plugin-react": "^6.2.0",
"faker": "^3.1.0",
"getstorybook": "^1.4.5"
}
}
My .eslintrc file >
// Temporary fix for errors caused by airbnb rules https://github.com/airbnb/javascript/issues/978
// "import/no-extraneous-dependencies": "off" and "settings": { "import/core-modules": [ "meteor/meteor" ] }
// added temperatery to to silence meteor import warning see issue > https://github.com/clayne11/eslint-import-resolver-meteor/issues/11
{
"extends": "airbnb",
"rules": {
"react/require-extension": "off",
"import/no-extraneous-dependencies": "off"
},
"settings": {
"import/core-modules": [ "meteor/meteor" ]
}
}
See my updated on the above question.
Error one can be fixed simply by adding "lint": "eslint .;exit 0" on the package.json file
Error 2 is currently been worked on in Github issue https://github.com/clayne11/eslint-import-resolver-meteor/issues/11 To temporarily silence the issues you can use .eslintrc in my example above.