web-dev-qa-db-ja.com

NPM「Node 8.9.4 LTSを使用してSails.js依存関係をインストールすると、「ENOENT:no such file or directory error」」

最近、コンピューターをアップグレードして、NodeおよびNPMの最新のLTSバージョンに:

  • Node.js 8.9.4
  • NPM 5.6.0

npm installでNPMの依存関係をインストールしようとしているSails.js 0.12.14アプリケーションがありますが、それを行うと、次のエラーが表示されます。

➜  web-service git:(feature/auth) ✗ npm install
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/package.json'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/README.md'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/LICENSE'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/index.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/CHANGELOG.md'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/camelCase.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/uniqueId.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/bindKey.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/unnest.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/bindAll.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/unset.js'
// a bunch of similar Lodash errors removed from here
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/T.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/zipWith.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/lastIndexOfFrom.js'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/oauth-sign):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/oauth-sign-b13c86db'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/mkdirp):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/mkdirp-c94c8047'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/mkdirp/node_modules/minimist):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/minimist-ba966a6e'

npm ERR! path /Users/Nag/Code/project/web-service/node_modules/.staging/sails-02afd14e/node_modules/@sailshq/body-parser
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/Nag/Code/project/web-service/node_modules/.staging/sails-02afd14e/node_modules/@sailshq/body-parser' -> '/Users/Nag/Code/project/web-service/node_modules/.staging/@sailshq/body-parser-6d1e8405'
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!     /Users/Nag/.npm/_logs/2018-01-22T14_40_13_889Z-debug.log

何が起こっているのかわからないようで、他のオンラインで適切な答えを見つけることができません。 npm cache clean --forcerm -rf node_modulesを実行し、同様のエラーで再試行しました。 Node〜6だったが、Node 8.9.4およびNPM 5.6.0にアップグレードした後、インストールされません。依存関係。これを解決するにはどうすればよいですか?

19
Nag

package-lock.jsonファイルを削除してみてください。

35
tantalum

許可なし、インターネットの問題なし、それはnpmの一般的な問題です。 yarn で問題を解決しました。

yarn install

または、no-optionalフラグを使用できます。

npm install --no-optional
4
coturiv

package-lock.jsonファイルを削除してから、必要なパッケージをインストールするだけです。すべてが機能します。

3
Neha Sharma

私はしばらくこれに苦労していましたが、次のことに関連しているようです。

A、B、Cの3つのモジュールがあるとします

モジュールAにはBとCが直接含まれます。モジュールBにはpackage.json依存関係のモジュールCも含まれます。

モジュールAのpackage.jsonの依存関係が次のようになっている場合:

"dependencies": {
     "C": "^1.0.0",
     "B": "^1.1.0"
}

上記のエラー、ENOENT、何とか、.stagingで何とかなる

一方、ネストされたインクルードでモジュールを最初にインクルードする場合:

"dependencies": {
     "B": "^1.1.0",
     "C": "^1.0.0"
}

エラーはなくなります。これは、ネストされた依存関係を持つnpmのバグのようで、エラーメッセージとログはあまり説明的ではありませんでした。依存関係ツリーを確認し、説明されているケースがあるかどうかを確認します。ある場合はそれが問題です。

2
Severun

「package-lock.json」を削除して再生成すると、通常この問題は解決しますが、一度に複数のパッケージをアップグレードする可能性が高いため、本質的に危険です。

私の場合、package-lock.jsonが参照している特定のパッケージバージョンが1つあり、それは依存関係の5レベルの深さでした。そのバージョンはnpmレジストリに存在しなくなったため、インストールが中断しました。どのパッケージがこの依存関係を引っ張っているのかを見つけ、問題を解決するためにそのパッケージをアップグレードする必要がありました。

2
jspru

私にとって、これらのエラーは本当の根本的な問題を隠していたことが判明しました。これは、サードパーティのnpmリポジトリ(Azure devops)の資格情報が期限切れになったことです。再実行する必要がありましたvsts-npm-auth -config .npmrc私の.npmrcファイル。

0