[英]Unable to install node modules because 'This is related to npm not being able to find a file.'
[英]What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that?
我正在嘗試在從ASP.NET Boilerplate獲得的 angular 項目文件夾中運行npm install
,但出現“與 npm 無法找到文件相關”的錯誤。
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install
npm WARN deprecated @types/moment@2.13.0: This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need @types/moment installed!
npm WARN codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'
npm ERR! path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jack\AppData\Roaming\npm-cache\_logs\2018-03-21T19_33_18_250Z-debug.log
我可以清楚地看到發生這種情況,因為我的node_modules
子文件夾僅包含一個文件夾結構,其中沒有任何文件。 該結構是:
node_modules\@angular-devkit\build-optimizer\node_modules
我安裝了節點 8.9.4、npm 5.6.0 和 angular-CLI 1.5.0 以及 typescript 2.0.0。 后兩個包已經全局安裝。
以下是package.json
文件內容:
{
"name": "MyProject",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 4200",
"hmr": "ng serve --host 0.0.0.0 --port 4200 4201 --hmr -e=hmr",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.3",
"@angular/common": "^5.0.3",
"@angular/compiler": "^5.0.3",
"@angular/core": "^5.0.3",
"@angular/forms": "^5.0.3",
"@angular/http": "^5.0.3",
"@angular/platform-browser": "^5.0.3",
"@angular/platform-browser-dynamic": "^5.0.3",
"@angular/router": "^5.0.3",
"@aspnet/signalr": "1.0.0-preview1-28189",
"@types/bootstrap": "^3.3.33",
"@types/jquery": "^3.2.12",
"@types/jquery.blockui": "0.0.28",
"@types/jquery.validation": "^1.16.3",
"@types/lodash": "^4.14.62",
"@types/moment": "^2.13.0",
"@types/moment-timezone": "^0.2.34",
"@types/signalr": "^2.2.33",
"@types/toastr": "^2.1.33",
"abp-ng2-module": "^1.3.0",
"abp-web-resources": "^3.3.0",
"animate.css": "^3.5.2",
"block-ui": "^2.70.1",
"bootstrap": "^3.3.7",
"bootstrap-select": "^1.12.2",
"chart.js": "^2.6.0",
"core-js": "^2.4.1",
"famfamfam-flags": "^1.0.0",
"flot": "^0.8.0-alpha",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"jquery-countto": "^1.2.0",
"jquery-migrate": "^3.0.0",
"jquery-slimscroll": "^1.3.8",
"jquery-sparkline": "^2.4.0",
"js-cookie": "^2.1.4",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
"morris.js": "^0.5.0",
"ngx-bootstrap": "^2.0.2",
"ngx-pagination": "^3.0.3",
"node-waves": "^0.7.5",
"push.js": "1.0.4",
"raphael": "^2.2.7",
"rxjs": "^5.5.2",
"signalr": "^2.2.1",
"simple-line-icons": "^2.4.1",
"spin.js": "^2.3.2",
"sweetalert": "^2.0.8",
"toastr": "^2.1.2",
"ts-helpers": "^1.1.2",
"web-animations-js": "^2.3.1",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/cli": "^1.5.4",
"@angular/compiler-cli": "^5.0.3",
"@angularclass/hmr": "^2.1.3",
"@types/jasmine": "^2.5.38",
"@types/node": "^8.0.27",
"codelyzer": "^3.1.2",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.4.1",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"nswag": "^11.12.7",
"protractor": "^5.1.1",
"ts-node": "^3.3.0",
"tslint": "^5.7.0",
"typescript": "2.4.2"
}
}
當我運行npm install
時,我可以看到包正在下載到.staging
文件夾中。 在運行finalize
命令時(參見下面的日志),我可以看到 package 文件夾正在合並並復制到某處,但除了第一組子文件夾之外,某處似乎不是我的node_modules
子文件夾,因為我如上所示。 當npm install
完成時, .staging
文件夾被刪除,我只剩下部分文件夾結構。
誠然,我是 Node 開發的新手——我通常在我們的 ASP.NET Web API 后端工作。 我試圖讓我的開發環境與我們的前端開發人員的開發環境同步。 我花了一天的大部分時間尋找解決方案。 我試過卸載並重新安裝 Node。 我嘗試了與我們的前端開發人員環境相匹配的不同版本。 我已經嘗試使用最新版本的 angular-CLI 和 typescript 並退回到我上面引用的版本,希望“需要對等”警告能夠得到解決。 我在這個網站上搜索過類似的答案。 我找到的最接近的一個仍然沒有答案。
這是npm錯誤output中引用的“完整日志”的結尾:
19577 silly saveTree | `-- tsutils@2.22.2
19577 silly saveTree +-- typescript@2.4.2
19577 silly saveTree +-- web-animations-js@2.3.1
19577 silly saveTree `-- zone.js@0.8.18
19578 warn codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19579 warn codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19580 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
19581 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'
19582 verbose optional SKIPPING OPTIONAL DEPENDENCY:
19582 verbose optional Please try running this command again as root/Administrator.
19583 verbose stack Error: ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19584 verbose cwd D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
19585 verbose Windows_NT 10.0.16299
19586 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
19587 verbose node v8.9.4
19588 verbose npm v5.6.0
19589 error path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript
19590 error code ENOENT
19591 error errno -4058
19592 error syscall rename
19593 error enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\@angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19594 error enoent This is related to npm not being able to find a file.
19595 verbose exit [ -4058, true ]
請指教。
以下步驟對我有用:
npm cache clean -f
rm -rf node_modules
npm i
這可能與 Angular 包中的損壞或包的不兼容有關。
請按照以下步驟解決問題。
更新
ASP.NET Boilerplate 建議這里使用 yarn 因為 npm 有一些問題。 它很慢並且不能始終如一地解決依賴關系,yarn 解決了這些問題並且它也與 npm 兼容。
我今天遇到了同樣的問題,這讓我發瘋了!!! 我所做的是升級到節點 8.10 並將我的 NPM 升級到最新的我卸載了 angular CLI
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
然后我從 NPM 驗證我的緩存,如果它不是最新的我清理它並再次運行安裝,如果 npm 版本 < 5 然后使用npm cache clean --force
npm install -g @angular/cli@latest
並創建了一個新的項目文件並創建了一個新的 angular 項目。
按照@viveknuna 的建議,我使用下載的安裝程序升級到最新版本的 node.js 和 npm。 我還使用下載的安裝程序安裝了最新版本的紗線。 然后,如下所示,我升級了 angular-cli 和 typescript。 這是這個過程的樣子:
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g @angular/cli@latest
C:\Users\Jack\AppData\Roaming\npm\ng -> C:\Users\Jack\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@1.7.3
added 75 packages, removed 166 packages, updated 61 packages and moved 24 packages in 29.084s
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g typescript
C:\Users\Jack\AppData\Roaming\npm\tsserver -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
C:\Users\Jack\AppData\Roaming\npm\tsc -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsc
+ typescript@2.7.2
updated 1 package in 2.427s
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>node -v
v8.10.0
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm -v
5.6.0
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn --version
1.5.1
此后,我在我的 angular 文件夾中運行了yarn
和npm start
,一切似乎都很好。 這是它的樣子:
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn
yarn install v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "win32" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@angular/cli > @schematics/angular@0.1.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".
warning "@angular/cli > @angular-devkit/schematics > @schematics/schematics@0.0.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".
warning " > codelyzer@3.2.2" has incorrect peer dependency "@angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0".
warning " > codelyzer@3.2.2" has incorrect peer dependency "@angular/core@^2.3.1 || >=4.0.0-beta <5.0.0".
[4/4] Building fresh packages...
Done in 232.79s.
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm start
> MyProject@0.0.0 start D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
> ng serve --host 0.0.0.0 --port 4200
** NG Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
Date: 2018-03-22T13:17:28.935Z
Hash: 8f226b6fa069b7c201ea
Time: 22494ms
chunk {account.module} account.module.chunk.js () 129 kB [rendered]
chunk {app.module} app.module.chunk.js () 497 kB [rendered]
chunk {common} common.chunk.js (common) 1.46 MB [rendered]
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 515 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.1 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 1.53 MB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 15.1 MB [initial] [rendered]
webpack: Compiled successfully.
嘗試以下步驟:
1. 確保你有最新的 npm (npm install -g npm)。
2. 為您的防病毒軟件添加一個例外,以忽略您項目中的 node_modules 文件夾。
3. $ rm -rf node_modules package-lock.json 。
4. $ npm 安裝
如果發生這種情況,則意味着您必須升級您的 node.js。 只需從您的 PC 或 Mac 上卸載您當前的節點,然后從https://nodejs.org/en/下載最新版本
就我而言
npm cache clean --force
也不起作用,我使用
紗線
一、全局安裝yarn
npm i -g yarn
然后,而不是“npm start”,我做,
yarn add
這對我有用。
就我而言,這個錯誤發生在一個新項目中。
這里提出的解決方案都沒有奏效,所以我只是重新安裝了所有軟件包並開始正常工作。
就我而言,我嘗試運行npm i firebase@7.8.2
並收到錯誤消息,因為開發服務器正在 vsc 上的另一個終端中運行。 點擊 ctrl+c, y 在那個終端中停止它,然后安裝工作。
就我而言,我必須創建一個新應用程序,重新安裝我的節點包,然后復制我的 src 文檔。 那奏效了。
將您的 firebase.json 更改為:
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
到:
{
"functions": {
}
}
快樂編碼
我試圖在保管箱內的文件夾中進行操作。 我認為 Dropbox 在上傳文件或其他內容時鎖定了文件,但沒有用。 它會在不同的地方失敗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.