我如何解决"找不到模块"错误

时间:2017-10-19 14:48:55

标签: npm webpack npm-install

我想在npm和webpack的帮助下使用React构建一个网站。我已经在我的机器上安装了npm,现在我正在尝试在我的机器上安装webpack。 我运行了以下命令:

npm i webpack -S

然后它会抛出错误。请在下面找到错误日志:

npm http 200 https://registry.npmjs.org/is-buffer
npm http GET https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz
npm http 200 https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz

> uglifyjs-webpack-plugin@0.4.6 postinstall /usr/local/litle-home/tkale/cvs/scurvyReact/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


module.js:340
    throw err;
          ^
Error: Cannot find module 'sync-exec'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/litle-home/tkale/cvs/scurvyReact/node_modules/webpack/node_modules/uglifyjs-webpack-plugin/lib/post_install.js:9:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
npm ERR! weird error 8
npm ERR! Error: ENOENT, open '/usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423156518-0.5044926188420504/package/fp/wrapperValue.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 2.6.32-696.10.2.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "i" "webpack" "-S"
npm ERR! cwd /usr/local/litle-home/tkale/cvs/scurvyReact
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm ERR! path /usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423156518-0.5044926188420504/package/fp/wrapperValue.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! tar pack Error reading /usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423163147-0.8487295310478657/package
npm ERR! addLocalDirectory Could not pack "/usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423163147-0.8487295310478657/package" to "/usr/local/litle-home/tkale/.npm/es5-ext/0.10.35/package.tgz"
npm ERR! Error: ENOENT, lstat '/usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423153445-0.9213839254807681/package/node_modules/ajv/dist/regenerator.min.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 2.6.32-696.10.2.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "i" "webpack" "-S"
npm ERR! cwd /usr/local/litle-home/tkale/cvs/scurvyReact
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm ERR! path /usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423153445-0.9213839254807681/package/node_modules/ajv/dist/regenerator.min.js
npm ERR! fstream_path /usr/local/litle-home/tkale/tmp/npm-1220-UQjjVtpG/1508423153445-0.9213839254807681/package/node_modules/ajv/dist/regenerator.min.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/local/litle-home/tkale/cvs/scurvyReact/npm-debug.log
npm ERR! not ok code 0

如果有帮助,也可以在下面找到package.json文件:

{
  "name": "React",
  "version": "1.0.0",
  "description": "Building website using React with help of npm and webpack",
  "main": "index.js",
  "scripts": {
    "test": "karma start",
    "start": "node server.js",
    "_comment": "start in the above line tells heroku how to start our app"
  },
  "author": "Tushar",
  "license": "XYZ"
}

请你帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

如果我正确读取错误,您似乎使用的是旧版本的节点和npm。尝试将这些更新到LTS甚至是最新版本。

您可以获取最新版本和/或安装说明here