I am attempting to use nodemon to run a node server in one of my projects with a react frontend. When I attempt to use yarn to invoke nodemon, I receive the following errors:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/william/Documents/GitHub/cribbageNginx/my-app/server/build/helperFunctions' imported from /Users/william/Documents/GitHub/cribbageNginx/my-app/server/build/index.js
at finalizeResolution (internal/modules/esm/resolve.js:272:11)
at moduleResolve (internal/modules/esm/resolve.js:649:10)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:692:13)
at Loader.resolve (internal/modules/esm/loader.js:97:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
at link (internal/modules/esm/module_job.js:41:36)
[nodemon] app crashed - waiting for file changes before starting...
To reproduce this error, I run the following commands.
From the github repository, https://github.com/wjonesusna2012/cribbageNginxServer
in the /my-app/server directory, I run yarn build (which builds successfully) and then yarn start which returns the above error.
I can see that the helperFunctions file exists in the server/build folder so I'm confused as to why that file cannot be found in the import statement.
For brevity's sake, the package.json and tsconfig files are included here, with all files available in the above link.
{
"compilerOptions": {
"target": "es2020",
"rootDir": "./",
"outDir": "./build",
"esModuleInterop": true,
"strict": true,
"moduleResolution": "node"
}
}
server/package.json
{
"name": "server",
"version": "1.0.0",
"main": "index.tsx",
"license": "MIT",
"devDependencies": {
"@types/express": "^4.17.9",
"@types/node": "^14.14.20",
"nodemon": "^2.0.7",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},
"scripts": {
"start": "nodemon",
"build": "rm -rf ./build && tsc --project ./"
},
"type": "module",
"dependencies": {
"commonjs": "^0.0.1"
}
}
Any help is greatly appreciated.
question from:
https://stackoverflow.com/questions/65924413/nodemon-unable-to-find-file-from-typescript-build 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…