我有一个让我困惑的语法错误。 我在运行的同一目录中有一个node_modules目录 npm run tsc,一切都很好,没有语法错误。
由于我将免除你的原因,我将node_modules目录移动到我的主目录,〜。没有目录更改,我重新运行npm run tsc并且我得到语法错误:
../../../../../node_modules/@types/react-select/index.d.ts(18,46): error TS1005: ',' expected.
../../../../../ node_modules/@types/react-select/index.d.ts(22,31):错误TS1005:','预计。 ../../../../../node_modules/@types/react-select/index.d.ts(23,27):错误TS1005:','预计。 ../../../../../node_modules/@types/react-select/index.d.ts(24,36):错误TS1005:','预计。 ../../../../../node_modules/@types/react-select/index.d.ts(29,39):错误TS1005:','预计。 ../../../../../node_modules/@types/react-select/index.d.ts(30,39):错误TS1005:','预计。
package.json是:
{
"name": "plugin",
"version": "7.0.1",
"scripts": {
"tsc": "tsc -p tsconfig.json",
"tsc:w": "tsc -p tsconfig.json -w",
"lite": "lite-server",
"start": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run lite\" "
},
"license": "MIT",
"dependencies": {
"@angular/common": "4.2.6",
"@angular/compiler": "4.2.6",
"@angular/compiler-cli": "4.2.6",
"@angular/core": "4.2.6",
"@angular/forms": "4.2.6",
"@angular/http": "4.2.6",
"@angular/platform-browser": "4.2.6",
"@angular/platform-browser-dynamic": "4.2.6",
"@angular/platform-server": "4.2.6",
"@angular/animations": "4.2.6",
"@angular/router": "4.2.6",
"ag-grid": "13.3.1",
"ag-grid-angular": "13.3.0",
"bootstrap": "3.3.6",
"core-js": "2.4.1",
"jquery": "3.1.1",
"lodash": "4.17.4",
"moment": "2.17.1",
"rxjs": "5.4.2",
"systemjs": "0.20.14",
"zone.js": "0.8.12",
"primeng": "^4.2.0",
"ng2-split-pane": "^1.3.1",
"font-awesome": "^4.7.0",
"base64-js": "1.2.1",
"@types/react": "^16.0.2",
"@types/react-select": "^1.0.58",
"lite-server": "2.2.2",
"typescript": "^2.4.2",
"concurrently": "3.5.0"
}
}
有什么想法吗?
答案 0 :(得分:0)
您的node_modules
目录必须与package.json
位于同一目录中。如果你移动一个而不是另一个,或者不在npm install
的目录中运行package.json
,那么节点无法找到它要查找的内容。
无论如何,您都不应该手动移动node_modules
文件夹。