How to delete a - javascript

I created an npm link inside a local dependency. I've since deleted that local dependency off my HDD.
Now I'm trying to delete this npm link.
I've tried:
npm rm --global dependency
npm uninstall dependency
npm unlink --no-save dependency
However, after doing all that, and after the code has been deleted from my HDD, npm link dependency still works when called from my main project. How to delete it properly? Here's my package.json:
{
"name": "myproject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack serve",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"copy-webpack-plugin": "^9.0.1",
"d3-array": "^3.0.1",
"d3-dsv": "^3.0.1",
"d3-format": "^3.0.1",
"d3-scale": "^4.0.0",
"d3-time-format": "^4.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.3.5"
},
"devDependencies": {
"#types/d3-array": "^3.0.1",
"#types/d3-dsv": "^3.0.0",
"#types/d3-format": "^3.0.1",
"#types/d3-scale": "^4.0.1",
"#types/d3-time-format": "^4.0.0",
"#types/react-dom": "^17.0.9",
"html-webpack-plugin": "^5.3.2",
"ts-loader": "^9.2.3",
"webpack": "^5.44.0",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2"
}
}

Can you post your package.json ?
Weird, this should works
npm unlink dependency
rm -rf node_modules && npm install
It was asked here How do I uninstall a package installed using npm link?
UPD
Can remove symlink from global node_modules.
Find where is global npm list -g and remove it
rm -rf `npm list -g | head -1`/node_modules/dependency

Related

Local npm install from file path not working

I followed Link to install the npm package from the file path
However, when I try to use it I am getting the following error.
Cannot file moduele '<module_name>' or its corresponding type declaration
Is there any tutorial to follow in order to install typescript-based npm package locally?
Here my package.json of the package i want to install
{
"name": "sqs",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf build && prettier --write src/ && tsc",
"start": "ts-node ./src/index.ts",
"start:prod": "npm run build && node ./dist/src/index.js",
"start:dev": "./node_modules/nodemon/bin/nodemon.js",
"lint": "eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "eslint --fix '*/**/*.{js,ts,tsx}'",
"prettier": "prettier -c ./src/**/*.{js,ts,tsx,scss,css,md}",
"prettier:fix": "prettier -c ./src/**/*.{js,ts,tsx,scss,css,md} --write"
},
"author": "Rohit Sthapit",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.820.0",
"nodemon": "^2.0.20",
"readline-sync": "^1.4.10",
"ts-node": "^10.9.1"
},
"devDependencies": {
"#types/dotenv": "^8.2.0",
"#typescript-eslint/eslint-plugin": "^5.36.2",
"#typescript-eslint/parser": "^5.36.2",
"dotenv": "^8.2.0",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
}
}
Usually for packages that support typescript, you would find a DT symbol when you open the package page in npm.
For installing the typescript package, you use npm i #types/{package_name}. For eg, in lodash's case you could do:
npm i #types/lodash
Hope it helps!!
use this,
npm install --save-dev #types/package-name

TypeORM error when trying to create migration in CLI

I'm trying to use the TypeORM CLI to create a migration. I followed their guide but when I run yarn run typeorm migration:generate I get the error:
$ typeorm-ts-node-commonjs migration:generate
/usr/bin/env: ‘node --require ts-node/register’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
error Command failed with exit code 127.
My package.json looks like this:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "tsc -w",
"start": "node dist/index.js",
"dev": "nodemon dist/index.js",
"start2": "ts-node src/index.ts",
"dev2": "nodemon --exec ts-node src/index.ts",
"typeorm": "typeorm-ts-node-commonjs"
},
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server-express": "^3.6.7",
"class-validator": "^0.13.2",
"cors": "^2.8.5",
"express": "^4.17.3",
"express-graphql": "^0.12.0",
"graphql": "^15.3.0",
"pg": "^8.7.3",
"reflect-metadata": "^0.1.13",
"ts-node": "^10.7.0",
"type-graphql": "^1.1.1",
"typeorm": "^0.3.4"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#types/node": "^17.0.23",
"nodemon": "^2.0.15",
"typescript": "^4.6.3"
}
}
I managed to solve this by installing the cli as described here https://orkhan.gitbook.io/typeorm/docs/using-cli#installing-cli
Install ts-node globally npm install -g ts-node
add the following script to package.json: "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js" instead of "typeorm": "typeorm-ts-node-commonjs"
then create a migration with:
yarn run typeorm migration:generate -p -d src/data-source.ts src/migrations/<filename without ending>
FYI For anyone facing similar issues: It took me a while to figure out that the various documentations on typeorm are confusing and conflicting at the moment because they just moved to v0.3.0 and not everything has been updated.

webpack-cli Unknown argument and SyntaxError

i'm new to prestashop theme development.
i had setup my local enviroment and all works fine.
i try to build a theme from the classic default theme.
i go into the _dev folted inside the theme and run "npm install".
next i run "npm run build" to run the script: "build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks"
and i get the following error:
> ADMIN#DESKTOP-5JOQKQA MINGW64 /c/laragon/www/PrestaShopDev/themes/prodet/_dev ((1.7.7.0))
> $ npm run build
>
> > prestashop-classic-dev-tools#1.0.0 build C:\laragon\www\PrestaShopDev\themes\prodet\_dev
> > NODE_ENV=production webpack --progress --colors --debug --display-chunks
>
> [webpack-cli] Unknown argument: --colors
> Did you mean --color?
> [webpack-cli] Unknown argument: --debug
> [webpack-cli] Unknown argument: --display-chunks
> Note: This command was run via npm module 'win-node-env'
> npm ERR! code ELIFECYCLE
> npm ERR! errno 2
> npm ERR! prestashop-classic-dev-tools#1.0.0 build: `NODE_ENV=production webpack --progress --colors --debug
> --display-chunks`
> npm ERR! Exit status 2
> npm ERR!
> npm ERR! Failed at the prestashop-classic-dev-tools#1.0.0 build 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\2020-12-11T16_17_37_009Z-debug.log
how can i fix it?
here is the package.json file:
{
"name": "prestashop-classic-dev-tools",
"version": "1.0.0",
"description": "Tools to help while developing the Classic theme",
"main": "index.js",
"scripts": {
"build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks",
"watch": "webpack --progress --colors --debug --display-chunks --watch"
},
"author": "PrestaShop",
"license": "AFL-3.0",
"devDependencies": {
"autoprefixer": "^6.7.7",
"babel-loader": "^8.2.2",
"bootstrap": "4.0.0-alpha.5",
"bootstrap-touchspin": "^3.1.1",
"bourbon": "^4.2.6",
"css-loader": "^5.0.1",
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"flexibility": "^1.0.5",
"jquery": "^3.5.1",
"jquery-touchswipe": "^1.6",
"jquery.browser": "^0.1.0",
"material-design-icons": "^2.1.3",
"node-sass": "^4.14.1",
"notosans-fontface": "~1.0.1",
"postcss-flexibility": "^1.0.2",
"postcss-loader": "^1.3.3",
"sass-loader": "^6.0.3",
"style-loader": "^0.14.1",
"tether": "^1.1.1",
"velocity-animate": "^1.2.3",
"webpack": "^5.10.0",
"webpack-cli": "^4.2.0",
"webpack-sources": "^0.1.0"
}
}
my node version is:
$ node -v
v10.18.1
my npm version is:
$ npm -v
6.13.4
i really don't understand how to fix this.
I am also new to prestashop development.
I had the same error.
I solved it using a second clone of the classic folder.
the error is probably due to the webpack version.
Here is the package.json
{
"name": "prestashop-classic-dev-tools",
"version": "1.0.0",
"description": "Tools to help while developing the Classic theme",
"main": "index.js",
"scripts": {
"build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks",
"watch": "webpack --progress --colors --debug --display-chunks --watch"
},
"author": "PrestaShop",
"license": "AFL-3.0",
"devDependencies": {
"autoprefixer": "^6.7.7",
"babel-loader": "^5.3.2",
"bootstrap": "4.0.0-alpha.5",
"bootstrap-touchspin": "^3.1.1",
"bourbon": "^4.2.6",
"css-loader": "^0.27.3",
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"flexibility": "^1.0.5",
"jquery": "^2.1.4",
"material-design-icons": "^2.1.3",
"node-sass": "^4.14.1",
"notosans-fontface": "~1.0.1",
"postcss-flexibility": "^1.0.2",
"postcss-loader": "^1.3.3",
"sass-loader": "^6.0.3",
"style-loader": "^0.14.0",
"tether": "^1.1.1",
"velocity-animate": "^1.2.3",
"webpack": "^2.2.1",
"webpack-sources": "^0.1.0"
}
}
in the clone after
npm install
npm run build
For me, it worked and compiles the theme

I am unable to install my project packages

I was getting error installing expressJs to my packages. I have had to do an npm cache clean --force no sucess, then I deleted my node_modules and package-lock.json, I try to reinstall packages using npm i I still got an error.
Now I deleted node.js from my pc windows 10 and downloaded and installed the latest node and tried to reinstall the project packages again. Now the error I get is this
$ npm i
npm ERR! Unexpected end of JSON input while parsing near '...ncies":{"autoprefixer'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Chioma Onyepere\AppData\Roaming\npm-cache\_logs\2019-05-28T20_26_29_676Z-debug.log
My app is built on nextJs
Here's the package.json
{
"name": "ratethis",
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next",
"build": "next build",
"now-build": "next build",
"start": "next start -p %PORT%"
},
"repository": {
"type": "git",
"url": "git+https://github.com/infinity-web-development/ratethis"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/infinity-web-development/ratethis/issues"
},
"homepage": "https://github.com/infinity-web-development/ratethis#readme",
"dependencies": {
"#zeit/next-css": "^1.0.1",
"antd": "^3.15.1",
"faker": "^4.1.0",
"next": "^8.0.3",
"next-images": "^1.1.1",
"next-redux-wrapper": "^3.0.0-alpha.2",
"now": "^15.0.6",
"prop-types": "^15.7.2",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react-polls": "^1.2.0",
"react-redux": "^7.0.1",
"redux": "^4.0.1",
"redux-saga": "^1.0.2",
"shallow-equal": "^1.1.0",
"uuid": "^3.3.2"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-plugin-import": "^1.11.0",
"babel-plugin-inline-import": "^3.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-standard": "^4.0.0",
"next-antd-aza-less": "^1.0.2"
}
}
Apparently error is from my pc cause it works just fine on another pc.
I don't know much about npm, but I'd suggesting trying to have it verify the installs it's already done and somehow rewrite the package.json file from the existing installs.
https://docs.npmjs.com/cli/cache.html
Even though the install failed and the package.json doesn't show any traces of the install, there could be some artifact that only npm knows about that's getting in the way.

React Native: App is getting disconnected right after getting installed into emulator

react-native run-android
after thing command app is getting installed into emulator succesfully but getting disconnected from terminal.
Package.json
{
"name": "AppName",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"clean": "npm cache verify && cd android && ./gradlew clean && cd ..",
"android": "npm run install && npm run start"
},
"dependencies": {
"react": "16.2.0",
"react-native": "0.53.0",
"react-native-facebook-login": "^1.6.0",
"react-native-splash-screen": "^3.0.6",
"react-navigation": "git+https://github.com/react-community/react-navigation.git",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-actions": "2.2.1",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "22.1.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.1.4",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
below image of Logcat in Android Studio.
I dint see anything suspicions. Thanks
Tried:
mkdir android/app/src/main/assets
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
and
cd android && ./gradlew clean && cd .. && react-native run-android

Categories

Resources