Skip to content

package.json scripts with nodemon do not find ts-node. #2340

Closed
@jlguenego

Description

@jlguenego

Note on possible duplicata: I have searched without success an existing issue with nodemon and ts-node, but not found.

Current Behavior:

Scripts declared in package.json under the scripts section do not behave as previous npm version (<7).
Example with nodemon, and ts-node (typescript):

{
  "name": "",
  "version": "0.0.0",
  "description": "",
  "main": "build/src/index.js",
  "types": "build/src/index.d.ts",
  "files": [
    "build/src"
  ],
  "license": "Apache-2.0",
  "keywords": [],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "lint": "gts lint",
    "clean": "gts clean",
    "compile": "tsc",
    "fix": "gts fix",
    "prepare": "npm.cmd run compile",
    "pretest": "npm.cmd run compile",
    "posttest": "npm.cmd run lint",
    "start": "nodemon src/index.ts"
  },
  "devDependencies": {
    "@types/node": "^14.11.2",
    "gts": "^3.0.3",
    "typescript": "^4.0.3",
    "nodemon": "^2.0.6",
    "ts-node": "^9.1.1"
  }
}

D:\formation\jlg-test>npm start

> start
> nodemon src/index.ts

[nodemon] 2.0.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/index.ts`
'ts-node' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...

Expected Behavior:

As with the previous npm version,

> start
> nodemon src/index.ts

[nodemon] 2.0.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src\index.ts`
Try npm run lint/fix!
[nodemon] clean exit - waiting for changes before restart

Steps To Reproduce:

mkdir jlg-test
cd jlg-test
npx gts init
npm i -D nodemon
npm i -D ts-node

add inside the package.json the start scripts:

"start": "nodemon src/index.ts"

Environment:

OS: Windows 10
Node v15.4.0
npm 7.0.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions