I had my server working with an earlier version of node.js, npm, and socket.io but after updating I started getting issues with socket.io:
$ node server.js
node.js:237
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module './lib/socket.io'
at Function._resolveFilename (module.js:333:15)
at Function._load (module.js:280:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/usr/local/lib/node_modules/socket.io/index.js:8:18)
at Module._compile (module.js:444:26)
at Object..js (module.js:462:10)
at Module.load (module.js:351:32)
at Function._load (module.js:309:12)
at Module.require (module.js:357:17)
Before upgrading I had a symlink for socket.io under node_modules pointing to the "centrally installed" directory with the same name. Recently I tried installing socket.io local to my project by issuing the command:
npm install socket.io
which placed socket.io under node_modules in my project. I found it strange at first that the error message was saying "./lib/socket.io" but when I looked into it I found that project/node_modules/socket.io/index.js is requiring socket.io like so:
module.exports = require('./lib/socket.io');
But there is nothing there except transport:
...project/node_modules/socket.io/lib
$ ll
total 24
drwxrwxr-x 3 ghbarratt dev 4096 Mar 26 14:38 .
drwxrwxr-x 5 ghbarratt dev 4096 Mar 26 15:03 ..
-rw-rw-r-- 1 ghbarratt dev 10777 Mar 6 16:37 transport.js
drwxrwxr-x 3 ghbarratt dev 4096 Mar 26 14:38 transports
Should there be another socket.io directory or a socket.io.js file under lib? Why would index.js be requiring an internal file that seems to be missing?
Versions:
node -v
v0.7.7-pre
npm -v
1.1.12
socket.io#0.9.2
Distributor ID: Ubuntu
Description: Ubuntu 10.10
Release: 10.10
Codename: maverick
I hate to answer my own question, but I did get things resolved and there were no other answers so I am going to add this in case it can help someone else.
With Felix Loether's comment (which I +1ed) I was fairly certain that I did not get all the files I should have during the npm install socket.io. I tried doing an apt-get update/upgrade, thinking that I might need an update for tar or something, but the results were still the same.
I was noticing a 304 response in the install output and wondered at that point if there was some sort of npm cache that I should try clearing. I discovered I could clear the npm cache with the command: npm cache clean. Cleaning the cache finally got me past the no-errors-until-runtime issue.
I then started to get an error message: make: node-waf: Command not found which lead me to reinstall node.
And after all that, it worked!
Related
Okay so I have been trying to deploy a Next app to my Ubuntu 20.04 vps but I am unable to do so. I have uploaded all the files from my local machine to the server via ftp and then after trying to install it gets stuck and then killed ( please check the image to see where it gets stuck ). The app works perfectly in my local machine.
I tried by deleting .next directory, node_modules directory as well as package-lock.json file but the problem prevails.
Here's the Node and NPM version in my local machine:
Node: v14.15.0
NPM: v7.14.0
This is the Node and NPM version in my server:
Node: v14.18.2
NPM: v8.3.0
I have also attached my package.json file incase you want to see the dependencies
UPDATE
I some how installed the dependencies but now I am getting different type of errors when I run 'npm run dev' or 'npm run build'.
Here's what I get after I run npm run dev:
[20:09] [server1.example.com boomboom] # npm run dev
> boomboom#0.1.0 dev
> next dev
warn - Port 3000 is in use, trying 3001 instead.
ready - started server on 0.0.0.0:3001, url: http://localhost:3001
info - Loaded env from /home/user1/node-apps/boomboom/.env.local
error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[4].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[4].use[2]!./styles/Footer.module.css
/home/user1/node-apps/boomboom/node_modules/source-map/lib/util.js:101
// above the root is a no-op. Therefore we can remove all '.
SyntaxError: Unexpected end of input
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: SyntaxError: /home/user1/node-apps/boomboom/node_modules/mongodb-connection-string-url/node_modules/whatwg-url/package.json (directory description file): SyntaxError: Unexpected end of JSON input
<w> while resolving 'whatwg-url' in /home/user1/node-apps/boomboom/node_modules/mongodb-connection-string-url to a directory
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: SyntaxError: /home/user1/node-apps/boomboom/node_modules/mongodb-connection-string-url/node_modules/whatwg-url/package.json (directory description file): SyntaxError: Unexpected end of JSON input
<w> while resolving 'whatwg-url' in /home/user1/node-apps/boomboom/node_modules/mongodb-connection-string-url to a directory
This is what I get after I run npm run build:
[20:13] [server1.example.com boomboom] # npm run build
> boomboom#0.1.0 build
> next build
info - Loaded env from /home/user1/node-apps/boomboom/.env.local
info - Checking validity of types
error - ESLint: Failed to load plugin 'react' declared in '.eslintrc.json » eslint-config-next/core-web-vitals » /home/user1/node-apps/boomboom/node_modules/eslint-config-next/index.js': Cannot find module 'eslint-plugin-react' Require stack: - /home/user1/node-apps/boomboom/node_modules/eslint-config-next/index.js Referenced from: /home/user1/node-apps/boomboom/node_modules/eslint-config-next/index.js
> Build error occurred
/home/user1/node-apps/boomboom/node_modules/source-map/lib/util.js:101
// above the root is a no-op. Therefore we can remove all '.
SyntaxError: Unexpected end of input
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/user1/node-apps/boomboom/node_modules/source-map/lib/source-map-generator.js:9:12)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
info - Creating an optimized production build .[20:13] [server1.example.com boomboom] #
I have a project where I built several modules. After finding that nestjs has a lib cli command I ported all of them to use this style.
Now my app can't find these modules when using npm run start:prod.
Error: Cannot find module '#app/foo'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/xxx/Development/nest-test/dist/src/app.service.js:13:15)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
I created a project with the basic code and one library to reproduce the problem: https://github.com/hkeio/nestjs-test
Even when I link the package node is not able to find the module.
cd libs/foo
npm link
cd ../..
npm link #app/foo
When running NODE_DEBUG=* npm run start:prod I can see that he is looking at the right place but does not find the module:
MODULE 12494: looking for "#app/foo" in [
"/Users/xxx/Development/nest-test/dist/src/node_modules",
"/Users/xxx/Development/nest-test/dist/node_modules",
"/Users/xxx/Development/nest-test/node_modules",
"/Users/xxx/Development/node_modules",
"/Users/xxx/node_modules",
"/Users/node_modules",
"/node_modules",
"/Users/xxx/.node_modules",
"/Users/xxx/.node_libraries",
"/Users/xxx/.nvm/versions/node/v10.15.3/lib/node"
]
...
$ pwd
/Users/xxx/Development/nest-test/node_modules
$ ll #app
total 0
drwxr-xr-x 3 xxx staff 96 May 30 09:04 .
drwxr-xr-x 608 xxx staff 19456 May 30 09:04 ..
lrwxr-xr-x 1 xxx staff 65 May 30 09:04 foo -> ../../../../.nvm/versions/node/v10.15.3/lib/node_modules/#app/foo```
According to the docs of tsconfig-paths it can be used when executing the built sources with node.
The issue comment you are referencing also mentions execution with node.
Actually the problem occurs when executing the built files with node dist/main.js, not during the build process with tsc.
I managed to get a working solution by following theses instructions from tsconfig-paths docs. #bisonfoutu created an example repo here.
Add a file named tsconfig-paths-bootstrap.js to the root of the project, and paste the code from the docs in it.
Change the start:prod script to: node -r ./tsconfig-paths-bootstrap.js dist/main.js
You should now be able to compile and execute the project with TS paths. (be aware that you will not be able to compile if there is no path set in tsconfig.json)
I am trying to deploy a reactjs app to an elastic beanstalk instance and seem to be encountering several issues.
1) I am receiving this error in the health section for elastic beanstalk:
/opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
node-sass#4.9.3 install /tmp/deployment/application/node_modules/node-sass
node scripts/install.js
Unable to save binary
/tmp/deployment/application/node_modules/node-sass/vendor/linux-x64-57
: { Error: EACCES: permission denied, mkdir
'/tmp/deployment/application/node_modules/node-sass/vendor' at
Object.fs.mkdirSync (fs.js:885:18) at sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:71:13) at
Function.sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:77:24) at
checkAndDownloadBinary
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:114:11)
at Object.
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30) at Object.Module._extensions..js
(module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad
(module.js:505:12) at Function.Module._load (module.js:497:3) errno:
-13, code: 'EACCES', syscall: 'mkdir', path: '/tmp/deployment/application/node_modules/node-sass/vendor' }
2) At the same time it appears as if node and npm are claiming all of the resources for my ec2 instance and this seems to continue even after the deployment fails.
What could be the cause of this failure? The other packages seems to be deploying as they are in the node_modules folder? Additionally, why would node take up resources in this fashion?
The reactjs app is using webpack and node-sass ^4.9.3 and node version 8.11.3 which works on my local environment.
Update: .npmrc solved the permission issue. I am still having a problem with the cpu being 100%. In the build script, the code is not getting past this line, I adding console.log lines at various points in the code:
let compiler = webpack(config);
After this line is hit, I am not seeing any advancement. Could this be a webpack issue?
I think this might the same issue described here
So apparently npm install takes too long during automated deployments
on t1.micro instances, bumping to a t2.small gives enough power to get
the task done.
There is an alternative js only module just called sass. Seems to work ok, but not as up to date as none-sass.
I downloaded the latest Node LTS Linux x86 binary tarball from here:
https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x86.tar.xz
And extracted it here:
/home/paul/dev/node-v8.12.0-linux-x86
I added Node's bin/ directory to my path:
$ echo $PATH
/home/paul/dev/node-v8.12.0-linux-x86/bin:/usr/local/bin:/usr/bin:/bin
And Node runs fine:
$ node -v
v8.12.0
However, when running npm, which is bundled with the Node binary tarballs, I get this:
$ npm -v
module.js:550
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
Enabling module's debugging shows the paths it is searching for to find the semver module:
MODULE 19001: Module._load REQUEST semver parent: /home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/lib/utils/unsupported.js
MODULE 19001: looking for "semver" in ["/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/lib/utils/node_modules","/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/lib/node_modules","/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/node_modules","/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules","/home/paul/dev/node-v8.12.0-linux-x86/node_modules","/home/paul/dev/node_modules","/home/paul/node_modules","/home/node_modules","/node_modules","/home/paul/.node_modules","/home/paul/.node_libraries","/home/paul/dev/node-v8.12.0-linux-x86/lib/node"]
In there I see this path:
/home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/node_modules
Which is where the semver module lives (as a dependent module of npm):
$ ls -al /home/paul/dev/node-v8.12.0-linux-x86/lib/node_modules/npm/node_modules/semver
total 80
drwxr-xr-x 3 paul paul 125 Sep 29 11:01 .
drwxr-xr-x 351 paul paul 12288 Sep 10 15:23 ..
drwxr-xr-x 2 paul paul 27 Sep 10 15:23 bin
-rw-r--r-- 1 paul paul 765 Feb 10 2018 LICENSE
-rw-r--r-- 1 paul paul 1598 Aug 17 17:42 package.json
-rw-r--r-- 1 paul paul 619 Aug 17 17:42 range.bnf
-rw-r--r-- 1 paul paul 14655 Aug 17 17:42 README.md
-rw-r--r-- 1 paul paul 36503 Aug 17 17:42 semver.js
So why can't Node resolve the semver module for npm?
For fun, I tried the latest 9.x release that supports x86, and it still fails, but gives a different message:
$ node -v
v9.11.2
$ npm -v
internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module '/home/paul/dev/node/bin/npm'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
Something is definitely up with Node's module resolution.
Thanks!
-Paul
I was having same problem with create-react-app
I don't know how but adding 'sudo' worked for me.
$ npm start
---> Giving Error same as yours
$ sudo npm start
---> Work Perfectly
hope it solve your problem
When I try to run an express app in nodeclipse, it gives me the error,
23 Jan 11:58:04 - [33m[nodemon] v1.0.13[39m
23 Jan 11:58:04 - [33m[nodemon] to restart at any time, enter rs[39m
23 Jan 11:58:04 - [33m[nodemon] watching: .[39m
23 Jan 11:58:04 - [32m[nodemon] starting node
/home/rdteam/workspace/NedvedNodeExpressTest/app.js[39m
[31m[nodemon] unable to run executable: "node"[39m
However, when I run from command line that
node /home/rdteam/workspace/NedvedNodeExpressTest/app.js
or
nodemon /home/rdteam/workspace/NedvedNodeExpressTest/app.js
both work without problem.
Pls help.
Regards
Hammer
In my case (running os x) I quick solved it setting the full path in :
/usr/local/lib/node_modules/nodemon/lib/monitor/run.js
function run(options) {
var cmd = config.command.raw;
//Added line
cmd.executable = '/usr/local/bin/node';
I was able to solve this problem by using the forever module, and configuring Nodeclipse's 'Node monitor path' to point to forever (*../npm/node_modules/forever/bin/forever*)
npm install forever
Open Eclipse -> Preferences -> Nodeclipse
Set the 'Node monitor path' to your installation of forever, and you're done.
I ran headlong into this problem whilst setting up Nodeclipse, and getting my node programs to work on Eclipse Kepler running on Mac OS X 10.8.5 (Mountain Lion)
The use case "Nodeclipse with nodemon":
Nodeclipse 0.9 Eclipse 4.2.2 Java 1.7 on win32
Configure Nodeclipse with monitor path C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js
logilog.js with console.log('done');
Run As -> Node with monitor
Produced command line (seen in Nodeclipse Console):
node --harmony C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js D:\Workspaces\ADT-Bundle\CountingServer\try\logilog.js
Console output
23 Jan 16:23:35 - [33m[nodemon] v0.7.10[0m
Error: ENOENT, no such file or directory 'D:\Workspaces\ADT-Bundle\CountingServer\try\undefined\nodemonCheckFsWatch1390465415226'
at Object.fs.openSync (fs.js:427:18)
at Object.watchFileChecker.check (C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js:154:22)
at ready (C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js:49:22)
at testAndStart (C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js:71:5)
at Object.<anonymous> (C:\Users\weibl\AppData\Roaming\npm\node_modules\nodemon\nodemon.js:847:1)
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)
23 Jan 16:23:35 - [33m[nodemon] to restart at any time, enter `rs`[0m
23 Jan 16:23:35 - [32m[nodemon] watching: D:\Workspaces\ADT-Bundle\CountingServer\try[0m
23 Jan 16:23:35 - [nodemon] exception in nodemon killing node
Created issues #118 https://github.com/Nodeclipse/nodeclipse-1/issues/118
That is how issues are reported.
Thank you for letting know that you need this. Check http://www.nodeclipse.org/ on news and how to help.
If you create a nodemon.json config file in your application folder (e.g. /home/rdteam/workspace/NedvedNodeExpressTest/nodemon.json) with the following JSON it should work without having to modify the Nodemon source files.
{
"exec": "/usr/local/bin/node"
}
This work on OS X, you may need to change the path depending on where you have node installed.
Details on Nodemon config files:
https://github.com/remy/nodemon#config-files