当我尝试使用npm start来启动一个空的服务器时,出现了这个错误,为什么它决定nodemon应该在那里,它不应该在node_module文件夹中吗?
The system cannot find the path specified.
node:internal/modules/cjs/loader:1042
throw err;
^
Error: Cannot find module 'C:\Users\PC\Desktop\New folder\nodemon\bin\nodemon.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.13.0
字符串
我的package.json
{
"name": "mongodb-tutorial",
"version": "1.0.0",
"description": "",
"main": "index.jss",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": " nodemon index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/express": "^4.17.17",
"express": "^4.18.2"
},
"dependencies": {
"nodemon": "^3.0.1"
}
}
型
tsconfig
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
型
我的index.ts
import express from "express";
const app = express();
const port = 3000;
app.listen(port, () => {
console.log(`server running on http://localhost:${port}`);
});
app.get("/", (req, res) => {
res.send("Welcome");
});
型
我现在什么都没试过,但我做了其他项目,效果很好
1条答案
按热度按时间dced5bon1#
我的目录名中有一个
&
,删除了它。这就解决了问题。