How do I solve "Cannot find module" error - npm

I want to build a website using React witht he help of npm and webpack. I have installed npm in my machine and now I am trying to install webpack in my machine.
I ran the following command:
npm i webpack -S
but then it throws error. Please find the error log below:
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
Incase it helps, also find package.json file below:
{
"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"
}
Could you please help me solve this issue.

If I read the error correctly, you seem to be using a really old version of node and npm. Try updating those to the LTS or even the latest release.
You can get the latest versions and/or installation instructions here.

Related

When I am installing expo on my pc, it is showing a error

I have installed node on E dir and I am installing expo for react-native
E:>npm i -g expo-cli
npm ERR! code ETARGET
npm ERR! notarget No matching version found for semver#^7.3.5.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jca\AppData\Local\npm-cache_logs\2021-05-03T05_32_28_520Z-debug.log
after this, when I am installing semver,
E:>npm install semver
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path E:
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'E:'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'E:'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'E:\'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm is failing to compile – uikit3

I've just started using UIKit3 (getuitkit.com) and I keep getting this error when npm run watch is running – I also can't use npm run compile either. Any ideas?
This is the error I get with watch...
[compile-less] /Users/Michael/Sites/uikit-3/build/icons.js:10
glob(custom, (err, folders) =>
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
[compile-less] [nodemon] app crashed - waiting for file changes before starting...
And this for compile...
/Users/Michael/Sites/uikit-3/build/icons.js:10
glob(custom, (err, folders) =>
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Darwin 16.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "icons"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! uikit#3.0.0-beta.18 icons: `node build/icons`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uikit#3.0.0-beta.18 icons script 'node build/icons'.
npm ERR! This is most likely a problem with the uikit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build/icons
npm ERR! You can get their info via:
npm ERR! npm owner ls uikit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Michael/Sites/uikit-3/npm-debug.log
npm ERR! Darwin 16.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "compile-less"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! uikit#3.0.0-beta.18 compile-less: `npm run icons && node build/less`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uikit#3.0.0-beta.18 compile-less script 'npm run icons && node build/less'.
npm ERR! This is most likely a problem with the uikit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run icons && node build/less
npm ERR! You can get their info via:
npm ERR! npm owner ls uikit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Michael/Sites/uikit-3/npm-debug.log
npm ERR! Darwin 16.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "compile"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! uikit#3.0.0-beta.18 compile: `npm run compile-less && npm run compile-js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uikit#3.0.0-beta.18 compile script 'npm run compile-less && npm run compile-js'.
npm ERR! This is most likely a problem with the uikit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run compile-less && npm run compile-js
npm ERR! You can get their info via:
npm ERR! npm owner ls uikit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Michael/Sites/uikit-3/npm-debug.log
You seem to be running node v0.12.0. UIkit's build tools require a minimum version of 4.4+. Please update to a current Node version. https://nodejs.org/en/

Encounter `npm ERR! error rolling back Error: ENOTEMPTY` when executing `npm install`

Recently, I study the ReactJS tutorial from a youtube video, link: https://youtu.be/MhkGQAoc7bc?t=2m45s, and I encounter many error when I run npm install in the 1-basic-react directory. In 1-basic-react directory, there is already the file package.json.
Content inside package.json:
{
"name": "react-tutorials",
"version": "0.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {},
"scripts": {
"dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Error Messages:
unbuild babel-types#6.10.2
unbuild babel-helper-define-map#6.9.0
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\nod
e_modules\babel-preset-es2015\node_modules\babel-plugin-transform-es2015-computed-properties\node_modules\babel-helper-d
efine-map\node_modules\babel-helper-function-name\node_modules\babel-traverse\node_modules\babylon\lib\tokenizer'
npm ERR! error rolling back babel-helper-define-map#6.9.0 { [Error: ENOTEMPTY, rmdir 'E:\Users\User\Documents\GitHub\re
act-js-tutorials\1-basic-react\node_modules\babel-preset-es2015\node_modules\babel-plugin-transform-es2015-computed-prop
erties\node_modules\babel-helper-define-map\node_modules\babel-helper-function-name\node_modules\babel-traverse\node_mod
ules\babylon\lib\tokenizer']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: 'E:\\Users\\User\\Documents\\GitHub\\react-js-tutorials\\1-basic-react\\node_modules
\\babel-preset-es2015\\node_modules\\babel-plugin-transform-es2015-computed-properties\\node_modules\\babel-helper-defin
e-map\\node_modules\\babel-helper-function-name\\node_modules\\babel-traverse\\node_modules\\babylon\\lib\\tokenizer' }
unbuild babel-template#6.9.0
unbuild babel-traverse#6.10.4
unbuild babel-helper-function-name#6.8.0
unbuild babel-runtime#6.9.2
npm WARN engine unicode-property-value-aliases#1.2.1: wanted: {"node":">=6"} (current: {"node":"v0.10.13","npm":"1.3.2"}
)
npm WARN engine unicode-property-aliases#1.1.0: wanted: {"node":">=6"} (current: {"node":"v0.10.13","npm":"1.3.2"})
npm ERR! Error: OK, write
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 Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\
\npm-cli.js" "install"
npm ERR! cwd E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! code OK
npm ERR! Error: OK, close
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 Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\
\npm-cli.js" "install"
npm ERR! cwd E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! code OK
npm ERR! Error: ENOENT, chmod 'E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\node_modules\babel-preset
-es2015\node_modules\babel-plugin-transform-es2015-object-super\node_modules\babel-runtime\node_modules\core-js\library\
modules\core.regexp.escape.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 Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\
\npm-cli.js" "install"
npm ERR! cwd E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! path E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\node_modules\babel-preset-es2015\node_modu
les\babel-plugin-transform-es2015-object-super\node_modules\babel-runtime\node_modules\core-js\library\modules\core.rege
xp.escape.js
npm ERR! fstream_path E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\node_modules\babel-preset-es2015\n
ode_modules\babel-plugin-transform-es2015-object-super\node_modules\babel-runtime\node_modules\core-js\library\modules\c
ore.regexp.escape.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! tar pack Error reading C:\Users\Casper\AppData\Local\Temp\npm-2516\1466863728585-0.9564304898958653\package
npm ERR! tar pack Error reading C:\Users\Casper\AppData\Local\Temp\npm-2516\1466863728585-0.9564304898958653\package
npm ERR! addLocalDirectory Could not pack "C:\\Users\\Casper\\AppData\\Local\\Temp\\npm-2516\\1466863728585-0.9564304898
958653\\package" to "C:\\Users\\Casper\\AppData\\Roaming\\npm-cache\\babel-messages\\6.8.0\\package.tgz"
npm ERR! addLocalDirectory Could not pack "C:\\Users\\Casper\\AppData\\Local\\Temp\\npm-2516\\1466863728585-0.9564304898
958653\\package" to "C:\\Users\\Casper\\AppData\\Roaming\\npm-cache\\babel-messages\\6.8.0\\package.tgz"
unbuild babel-traverse#6.10.4
unbuild babel-template#6.9.0
unbuild babel-types#6.10.2
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\nod
e_modules\babel-preset-stage-0\node_modules\babel-preset-stage-1\node_modules\babel-plugin-transform-class-constructor-c
all\node_modules\babel-runtime\node_modules\core-js\modules'
npm ERR! error rolling back babel-plugin-transform-class-constructor-call#6.8.0 { [Error: ENOTEMPTY, rmdir 'E:\Users\Us
er\Documents\GitHub\react-js-tutorials\1-basic-react\node_modules\babel-preset-stage-0\node_modules\babel-preset-stage-1
\node_modules\babel-plugin-transform-class-constructor-call\node_modules\babel-runtime\node_modules\core-js\modules']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: 'E:\\Users\\User\\Documents\\GitHub\\react-js-tutorials\\1-basic-react\\node_modules
\\babel-preset-stage-0\\node_modules\\babel-preset-stage-1\\node_modules\\babel-plugin-transform-class-constructor-call\
\node_modules\\babel-runtime\\node_modules\\core-js\\modules' }
unbuild babel-runtime#6.9.2
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! E:\Users\User\Documents\GitHub\react-js-tutorials\1-basic-react\npm-debug.log
npm ERR! not ok code 0
Based on your comment, you've got some kind of PATH problem. At a command line, you can type echo %PATH% and look for multiple entries that point to a node directory.
You'll need to edit your path so that only the directory with the latest copy of node is there. There are instructions for doing this on Windows 7 on other Stack sites.
One thing to be careful about: if you've installed global modules, they are very likely in the v0.10.13 directory tree. Make note of them before you change anything with an npm ls -g --depth=0 as you will likely need to reinstall these global modules once you fix the path issue.

Installing bower is throwing errors

I can't seem to install bower properly. I don't know what's wrong, but it keeps throwing these errors. Can someone help?
npm ERR! tar.unpack untar error /Users/Jeanwoo/.npm/bower/1.4.1/package.tgz
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! node v0.12.5
npm ERR! npm v2.11.2
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Jeanwoo/npm-debug.log
I'm assuming the command you're running is npm install -g bower (to install Bower globally on your machine).
The error
Please try running this command again as root/Administrator
...makes me think you should try running as root:
sudo npm install -g bower
And then input your password and it should install. If not, what is the command you're running?

Bower installation on a vagrant machine

I am trying to install bower on a vagrant machine using following command
npm install -g bower
but i am getting following error
npm WARN prefer global bower#1.3.2 should be installed with -g
npm http GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
[4mRunning "watch" task[24m
Waiting...npm http GET https://registry.npmjs.org/bower/-/bower-1.3.2.tgz
npm http 200 https://registry.npmjs.org/bower/-/bower-1.3.2.tgz
npm ERR! Error: EACCES, mkdir '/usr/lib/node_modules/bower'
npm ERR! { [Error: EACCES, mkdir '/usr/lib/node_modules/bower']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bower" "--no-bin-links"
npm ERR! cwd /vagrant
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/lib/node_modules/bower
npm ERR! fstream_path /usr/lib/node_modules/bower
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/lib/node_modules/bower'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /vagrant/npm-debug.log
npm ERR! not ok code 0
/tmp/vagrant-shell: line 44: bower: command not found
It seems that bower is not simplly gets installed on a windows machine.
Please help in issue.
Any help will be appericiated.
You need root access for global install.
sudo npm install -g bower