0

Windows 10 and Node version 16.13.1

I have a custom script in my package.json.When i trying to install npm packages,it's giving be bellow error;

URL=http://172.xxx.xx/repository/npm-registry

'URL' is not recognized as an internal or external command, operable program or batch file. npm ERR! code 1

Package.json

"scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "node index.js",
    "dev": "nodemon",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest --config=jest.json",
    "test:watch": "jest --watch --config=jest.json",
    "test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
    "preinstall": "URL=http://172.xxx.xx./repository/npm-registry"
  },
Tje123
  • 729
  • 17
  • 44
  • Does this answer your question? [How can I set NODE\_ENV=production on Windows?](https://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-on-windows) – Phil Mar 21 '22 at 04:51
  • Highly recommend [env-cmd](https://github.com/toddbluhm/env-cmd) – Phil Mar 21 '22 at 04:54
  • `npm config set registry http://172.xxx.xx./repository/npm-registry` or create `.npmrc` with content: `registry=http://172.xxx.xx./repository/npm-registry` also if You want to set env vars use `.env` file format and use `dotenv` package in app to read that file contents, `env-cmd` package is also deal, depending on Your favour. – num8er Mar 21 '22 at 14:32

1 Answers1

1

Add set before the preinstall script. like this:

"scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "node index.js",
    "dev": "nodemon",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest --config=jest.json",
    "test:watch": "jest --watch --config=jest.json",
    "test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
    "preinstall": "set URL=http://172.xxx.xx./repository/npm-registry"
  },
CY-OD
  • 336
  • 2
  • 8